Socket
Socket
Sign inDemoInstall

pubnub

Package Overview
Dependencies
Maintainers
5
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pubnub - npm Package Compare versions

Comparing version 4.27.0 to 4.27.1

yarn.lock

18

CHANGELOG.md

@@ -1,5 +0,19 @@

## [v4.27.0](https://github.com/pubnub/javascript/tree/v4.27.0)
September-27-2019
## [v4.27.1](https://github.com/pubnub/javascript/tree/v4.27.1)
November-20-2019
[Full Changelog](https://github.com/pubnub/javascript/compare/v4.27.0...v4.27.1)
- ⭐ Make changes in fetch_messages endpoint to move message actions (if any) for message from 'data' to 'actions' property (old 'data' will be in place for few updates to not break existing clients).
- ⭐ fix PAMv3 tests mocked signature
- ⭐ fix lint warnings for tests and code
- ⭐ fix gulp build so that failures in test and lint will trigger failure in travis
## [v4.27.0](https://github.com/pubnub/javascript/tree/v4.27.0)
October-08-2019
[Full Changelog](https://github.com/pubnub/javascript/compare/v4.26.1...v4.27.0)

@@ -6,0 +20,0 @@

3

gulpfile.babel.js

@@ -26,2 +26,3 @@ /* eslint no-console: 0, arrow-body-style: 0 */

gulp.on('error', process.exit.bind(process, 1));
gulp.task('clean', () => {

@@ -192,2 +193,2 @@ return gulp

runSequence('clean', 'babel', 'webpack', 'uglify_web', 'uglify_titanium', 'create_version', 'create_version_gzip', done);
});
});

@@ -258,3 +258,3 @@ "use strict";

value: function getVersion() {
return '4.27.0';
return '4.27.1';
}

@@ -261,0 +261,0 @@ }, {

{
"name": "pubnub",
"version": "4.27.0",
"version": "4.27.1",
"author": "PubNub <support@pubnub.com>",

@@ -5,0 +5,0 @@ "description": "Publish & Subscribe Real-time Messaging with PubNub",

@@ -25,3 +25,3 @@ # PubNub JavaScript SDK (V4)

* https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.1.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.27.1.js

@@ -299,3 +299,3 @@ /* @flow */

getVersion(): string {
return '4.27.0';
return '4.27.1';
}

@@ -302,0 +302,0 @@

@@ -62,3 +62,3 @@ /* @flow */

/** @type GetMessageActionsResponse */
let response = { data: getMessageActionsResponse.data };
let response = { data: getMessageActionsResponse.data, start: null, end: null };

@@ -65,0 +65,0 @@ if (response.data.length) {

@@ -101,3 +101,2 @@ /* @flow */

announce.channel = channelName;
announce.subscription = null;
announce.timetoken = messageEnvelope.timetoken;

@@ -107,2 +106,5 @@ announce.message = __processMessage(modules, messageEnvelope.message);

if (messageEnvelope.actions) {
announce.actions = messageEnvelope.actions;
// This should be kept for few updates for existing clients consistency.
announce.data = messageEnvelope.actions;

@@ -109,0 +111,0 @@ }

@@ -1,2 +0,2 @@

/* global describe, beforeEach, afterEach, it, before, after */
/* global describe, beforeEach, afterEach, it, after */
/* eslint no-console: 0 */

@@ -21,3 +21,3 @@

client.publish(payload, (status, response) => {
publishCompleted++;
publishCompleted += 1;

@@ -31,9 +31,8 @@ if (!status.error) {

if (publishCompleted < count) {
publish(publishCompleted);
} else if (publishCompleted === count) {
completion(messages);
}
if (publishCompleted < count) {
publish(publishCompleted);
} else if (publishCompleted === count) {
completion(messages);
}
);
});
};

@@ -54,8 +53,8 @@

for (let messageIdx = 0; messageIdx < messageTimetokens.length; messageIdx++) {
for (let messageIdx = 0; messageIdx < messageTimetokens.length; messageIdx += 1) {
const messageTimetoken = messageTimetokens[messageIdx];
for (let messageActionIdx = 0; messageActionIdx < count; messageActionIdx++) {
for (let messageActionIdx = 0; messageActionIdx < count; messageActionIdx += 1) {
/** @type MessageAction */
const action = { type: types[(messageActionIdx + 1)%3], value: values[(messageActionIdx + 1)%10] };
const action = { type: types[(messageActionIdx + 1) % 3], value: values[(messageActionIdx + 1) % 10] };

@@ -72,3 +71,3 @@ actionsToAdd.push({ messageTimetoken, action });

(status, response) => {
actionsAdded++;
actionsAdded += 1;

@@ -114,4 +113,4 @@ if (!status.error) {

pubnub = new PubNub({
subscribeKey: subscribeKey,
publishKey: publishKey,
subscribeKey,
publishKey,
uuid: 'myUUID',

@@ -148,3 +147,2 @@ });

},
subscription: null,
timetoken: '11',

@@ -157,3 +155,2 @@ },

},
subscription: null,
timetoken: '12',

@@ -168,3 +165,2 @@ },

},
subscription: null,
timetoken: '21',

@@ -177,3 +173,2 @@ },

},
subscription: null,
timetoken: '22',

@@ -218,3 +213,2 @@ },

},
subscription: null,
timetoken: '11',

@@ -227,3 +221,2 @@ },

},
subscription: null,
timetoken: '12',

@@ -238,3 +231,2 @@ },

},
subscription: null,
timetoken: '21',

@@ -247,3 +239,2 @@ },

},
subscription: null,
timetoken: '22',

@@ -281,3 +272,3 @@ },

{ channels: ['channelA', 'channelB'], includeMessageActions: true },
(status, response) => {}
() => {}
);

@@ -292,3 +283,3 @@ } catch (error) {

it('supports actions', (done) => {
it('supports actions (stored as \'data\' field)', (done) => {
const channel = PubNub.generateUUID();

@@ -299,3 +290,3 @@ const expectedMessagesCount = 2;

publishMessagesToChannel(pubnub, expectedMessagesCount, channel, (messages) => {
const messageTimetokens = messages.map((message) => message.timetoken );
const messageTimetokens = messages.map((message) => message.timetoken);

@@ -313,3 +304,3 @@ addActionsInChannel(pubnub, expectedActionsCount, messageTimetokens, channel, (actions) => {

let actionFound = false;
historyActionsCount++;
historyActionsCount += 1;

@@ -328,4 +319,3 @@ actions.forEach((action) => {

assert.equal(fetchedMessages[0].timetoken, messageTimetokens[0]);
assert.equal(fetchedMessages[fetchedMessages.length - 1].timetoken,
messageTimetokens[messageTimetokens.length - 1]);
assert.equal(fetchedMessages[fetchedMessages.length - 1].timetoken, messageTimetokens[messageTimetokens.length - 1]);

@@ -338,2 +328,44 @@ done();

}).timeout(60000);
it('supports actions (stored as \'actions\' field)', (done) => {
const channel = PubNub.generateUUID();
const expectedMessagesCount = 2;
const expectedActionsCount = 4;
publishMessagesToChannel(pubnub, expectedMessagesCount, channel, (messages) => {
const messageTimetokens = messages.map((message) => message.timetoken);
addActionsInChannel(pubnub, expectedActionsCount, messageTimetokens, channel, (actions) => {
setTimeout(() => {
pubnub.fetchMessages({ channels: [channel], includeMessageActions: true }, (status, response) => {
assert.equal(status.error, false);
const fetchedMessages = response.channels[channel];
const actionsByType = fetchedMessages[0].actions;
let historyActionsCount = 0;
Object.keys(actionsByType).forEach((actionType) => {
Object.keys(actionsByType[actionType]).forEach((actionValue) => {
let actionFound = false;
historyActionsCount += 1;
actions.forEach((action) => {
if (action.value === actionValue) {
actionFound = true;
}
});
assert.equal(actionFound, true);
});
});
assert.equal(historyActionsCount, expectedActionsCount);
assert.equal(fetchedMessages[0].timetoken, messageTimetokens[0]);
assert.equal(fetchedMessages[fetchedMessages.length - 1].timetoken, messageTimetokens[messageTimetokens.length - 1]);
done();
});
}, 2000);
});
});
}).timeout(60000);
});

@@ -11,2 +11,3 @@ /* global describe, beforeEach, it, before, after */

describe('grant token endpoint', () => {
let originalVersionFunction = null;
let pubnub;

@@ -25,2 +26,3 @@ let clock;

nock.enableNetConnect();
pubnub._config.getVersion = originalVersionFunction;
});

@@ -37,2 +39,7 @@

});
if (originalVersionFunction === null) {
originalVersionFunction = pubnub._config.getVersion;
pubnub._config.getVersion = () => 'testVersion';
}
});

@@ -50,3 +57,3 @@

timestamp: 1571360790,
signature: 'v2.CLurDTyT2OL1mMlQEUHEwfXqXvjSJ_NHTgJvgkG_5ek',
signature: 'v2.pJobOYLaDTsauQo8UZa-4Eu4JKYYRuaeyPS8IHpNN-E',
})

@@ -82,3 +89,3 @@ .reply(

timestamp: 1571360790,
signature: 'v2.CLurDTyT2OL1mMlQEUHEwfXqXvjSJ_NHTgJvgkG_5ek',
signature: 'v2.pJobOYLaDTsauQo8UZa-4Eu4JKYYRuaeyPS8IHpNN-E',
})

@@ -119,3 +126,3 @@ .reply(

timestamp: 1571360790,
signature: 'v2.CLurDTyT2OL1mMlQEUHEwfXqXvjSJ_NHTgJvgkG_5ek',
signature: 'v2.pJobOYLaDTsauQo8UZa-4Eu4JKYYRuaeyPS8IHpNN-E',
})

@@ -156,3 +163,3 @@ .reply(

timestamp: 1571360790,
signature: 'v2.CLurDTyT2OL1mMlQEUHEwfXqXvjSJ_NHTgJvgkG_5ek',
signature: 'v2.pJobOYLaDTsauQo8UZa-4Eu4JKYYRuaeyPS8IHpNN-E',
})

@@ -193,3 +200,3 @@ .reply(

timestamp: 1571360790,
signature: 'v2.CLurDTyT2OL1mMlQEUHEwfXqXvjSJ_NHTgJvgkG_5ek',
signature: 'v2.pJobOYLaDTsauQo8UZa-4Eu4JKYYRuaeyPS8IHpNN-E',
})

@@ -231,3 +238,3 @@ .reply(

timestamp: 1571360790,
signature: 'v2.CLurDTyT2OL1mMlQEUHEwfXqXvjSJ_NHTgJvgkG_5ek',
signature: 'v2.pJobOYLaDTsauQo8UZa-4Eu4JKYYRuaeyPS8IHpNN-E',
})

@@ -234,0 +241,0 @@ .reply(

@@ -1,2 +0,2 @@

/* global describe, beforeEach, afterEach, it, before, after */
/* global describe, beforeEach, afterEach, it, after */
/* eslint no-console: 0 */

@@ -21,18 +21,17 @@

client.publish(payload, (status, response) => {
publishCompleted++;
publishCompleted += 1;
if (!status.error) {
messages.push({ message: payload.message, timetoken: response.timetoken });
messages = messages.sort((left, right) => left.timetoken - right.timetoken);
} else {
console.error('Publish did fail:', status);
}
if (!status.error) {
messages.push({ message: payload.message, timetoken: response.timetoken });
messages = messages.sort((left, right) => left.timetoken - right.timetoken);
} else {
console.error('Publish did fail:', status);
}
if (publishCompleted < count) {
publish(publishCompleted);
} else if (publishCompleted === count) {
completion(messages);
}
if (publishCompleted < count) {
publish(publishCompleted);
} else if (publishCompleted === count) {
completion(messages);
}
);
});
};

@@ -63,4 +62,4 @@

pubnub = new PubNub({
subscribeKey: subscribeKey,
publishKey: publishKey,
subscribeKey,
publishKey,
uuid: 'myUUID',

@@ -67,0 +66,0 @@ });

@@ -1,8 +0,8 @@

/* global describe, beforeEach, afterEach, it, before, after, jasmine */
/* global describe, beforeEach, afterEach, it, after */
/* eslint no-console: 0 */
import PubNub from '../../../src/node/index';
import utils from "../../utils";
import assert from 'assert';
import nock from 'nock';
import PubNub from '../../../src/node/index';
import utils from '../../utils';

@@ -20,3 +20,3 @@

(status, response) => {
publishCompleted++;
publishCompleted += 1;

@@ -51,6 +51,6 @@ if (!status.error) {

for (let messageIdx = 0; messageIdx < messageTimetokens.length; messageIdx++) {
for (let messageIdx = 0; messageIdx < messageTimetokens.length; messageIdx += 1) {
const messageTimetoken = messageTimetokens[messageIdx];
for (let messageActionIdx = 0; messageActionIdx < count; messageActionIdx++) {
for (let messageActionIdx = 0; messageActionIdx < count; messageActionIdx += 1) {
/** @type MessageAction */

@@ -69,3 +69,3 @@ const action = { type: types[(messageActionIdx + 1) % 3], value: values[(messageActionIdx + 1) % 10] };

(status, response) => {
actionsAdded++;
actionsAdded += 1;

@@ -110,4 +110,4 @@ if (!status.error) {

pubnub = new PubNub({
subscribeKey: subscribeKey,
publishKey: publishKey,
subscribeKey,
publishKey,
uuid: 'myUUID',

@@ -124,9 +124,9 @@ authKey: 'myAuthKey',

.createNock()
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
pubnub.addMessageAction({
channel: 'test-channel',
messageTimetoken: '1234567890',
})
channel: 'test-channel',
messageTimetoken: '1234567890',
})
.catch((err) => {

@@ -143,11 +143,11 @@ assert.equal(scope.isDone(), false);

.createNock()
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
const action = { value: 'test value' };
pubnub.addMessageAction({
channel: 'test-channel',
messageTimetoken: '1234567890',
action,
})
channel: 'test-channel',
messageTimetoken: '1234567890',
action,
})
.catch((err) => {

@@ -164,11 +164,11 @@ assert.equal(scope.isDone(), false);

.createNock()
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
const action = { type: PubNub.generateUUID(), value: 'test value' };
pubnub.addMessageAction({
channel: 'test-channel',
messageTimetoken: '1234567890',
action,
})
channel: 'test-channel',
messageTimetoken: '1234567890',
action,
})
.catch((err) => {

@@ -185,11 +185,11 @@ assert.equal(scope.isDone(), false);

.createNock()
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
const action = { type: 'custom' };
pubnub.addMessageAction({
channel: 'test-channel',
messageTimetoken: '1234567890',
action,
})
channel: 'test-channel',
messageTimetoken: '1234567890',
action,
})
.catch((err) => {

@@ -206,10 +206,10 @@ assert.equal(scope.isDone(), false);

.createNock()
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/`)
.reply(200, {});
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/`)
.reply(200, {});
const action = { type: 'custom', value: 'test value' };
pubnub.addMessageAction({
channel: 'test-channel',
action,
})
channel: 'test-channel',
action,
})
.catch((err) => {

@@ -226,10 +226,10 @@ assert.equal(scope.isDone(), false);

.createNock()
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
.post(`/v1/message-actions/${subscribeKey}/channel/test-channel/message/1234567890`)
.reply(200, {});
const action = { type: 'custom', value: 'test value' };
pubnub.addMessageAction({
messageTimetoken: '1234567890',
action,
})
messageTimetoken: '1234567890',
action,
})
.catch((err) => {

@@ -248,5 +248,5 @@ assert.equal(scope.isDone(), false);

publishMessages(pubnub,1, channel, (timetokens) => {
publishMessages(pubnub, 1, channel, (timetokens) => {
pubnub.addMessageAction(
{ channel: channel, messageTimetoken: timetokens[0], action: messageAction },
{ channel, messageTimetoken: timetokens[0], action: messageAction },
(status, response) => {

@@ -277,13 +277,13 @@ assert.equal(status.error, false);

.reply(207, {
"status": 207,
"data": {
"type": "reaction",
"value": "smiley_face",
"uuid": "user-456",
"actionTimetoken": '15610547826970050',
"messageTimetoken": '15610547826969050'
status: 207,
data: {
type: 'reaction',
value: 'smiley_face',
uuid: 'user-456',
actionTimetoken: '15610547826970050',
messageTimetoken: '15610547826969050'
},
"error": {
"message": "Stored but failed to publish message action.",
"source": "actions"
error: {
message: 'Stored but failed to publish message action.',
source: 'actions'
}

@@ -294,3 +294,3 @@ });

{ channel: 'test-channel', messageTimetoken: '1234567890', action: { type: 'custom', value: 'test' } },
(status, response) => {
(status) => {
assert.equal(scope.isDone(), true);

@@ -316,3 +316,3 @@ assert.equal(status.statusCode, 207);

{ channel, message: { hello: 'test' }, sendByPost: true },
(status, response) => {
(publishStatus, response) => {
messageTimetoken = response.timetoken;

@@ -354,5 +354,5 @@

pubnub.removeMessageAction({
channel: 'test-channel',
actionTimetoken: '1234567890',
})
channel: 'test-channel',
actionTimetoken: '1234567890',
})
.catch((err) => {

@@ -374,5 +374,5 @@ assert.equal(scope.isDone(), false);

pubnub.removeMessageAction({
channel: 'test-channel',
messageTimetoken: '1234567890',
})
channel: 'test-channel',
messageTimetoken: '1234567890',
})
.catch((err) => {

@@ -394,5 +394,5 @@ assert.equal(scope.isDone(), false);

pubnub.removeMessageAction({
messageTimetoken: '1234567890',
actionTimetoken: '12345678901',
})
messageTimetoken: '1234567890',
actionTimetoken: '12345678901',
})
.catch((err) => {

@@ -418,9 +418,9 @@ assert.equal(scope.isDone(), false);

{ channel, actionTimetoken: actionTimetokens[0], messageTimetoken: messageTimetokens[0] },
(status) => {
assert.equal(status.error, false);
(removeMessageStatus) => {
assert.equal(removeMessageStatus.error, false);
setTimeout(() => {
pubnub.getMessageActions({ channel }, (status, response) => {
assert.equal(status.error, false);
assert.equal(response.data.length, 0);
pubnub.getMessageActions({ channel }, (getMessagesStatus, getMessagesResponse) => {
assert.equal(getMessagesStatus.error, false);
assert.equal(getMessagesResponse.data.length, 0);

@@ -446,5 +446,5 @@ done();

pubnub.removeMessageAction(
{channel, actionTimetoken: actionTimetokens[0], messageTimetoken: messageTimetokens[0]},
(status) => {
assert.equal(status.error, false);
{ channel, actionTimetoken: actionTimetokens[0], messageTimetoken: messageTimetokens[0] },
(removeMessagesStatus) => {
assert.equal(removeMessagesStatus.error, false);
}

@@ -526,4 +526,4 @@ );

assert.equal(status.error, false);
const firstFetchedActionTimetoken = response.data[0].actionTimetoken;
const lastFetchedActionTimetoken = response.data[response.data.length - 1].actionTimetoken;
let firstFetchedActionTimetoken = response.data[0].actionTimetoken;
let lastFetchedActionTimetoken = response.data[response.data.length - 1].actionTimetoken;
assert.equal(firstFetchedActionTimetoken, middlePublishedActionTimetoken);

@@ -537,14 +537,15 @@ assert.equal(lastFetchedActionTimetoken, lastPublishedActionTimetoken);

{ channel, start: middlePublishedActionTimetoken, limit: halfSize },
(status, response) => {
assert.equal(status.error, false);
const firstFetchedActionTimetoken = response.data[0].actionTimetoken;
const lastFetchedActionTimetoken = response.data[response.data.length - 1].actionTimetoken;
(getMessageActionsStatus, getMessageActionsResponse) => {
assert.equal(getMessageActionsStatus.error, false);
firstFetchedActionTimetoken = getMessageActionsResponse.data[0].actionTimetoken;
lastFetchedActionTimetoken = getMessageActionsResponse.data[getMessageActionsResponse.data.length - 1].actionTimetoken;
assert.equal(firstFetchedActionTimetoken, firstPublishedActionTimetoken);
assert.equal(lastFetchedActionTimetoken, middleMinusOnePublishedActionTimetoken);
assert.equal(response.data.length, halfSize);
assert.equal(response.start, firstPublishedActionTimetoken);
assert.equal(response.end, middleMinusOnePublishedActionTimetoken);
assert.equal(getMessageActionsResponse.data.length, halfSize);
assert.equal(getMessageActionsResponse.start, firstPublishedActionTimetoken);
assert.equal(getMessageActionsResponse.end, middleMinusOnePublishedActionTimetoken);
done();
});
}
);
});

@@ -551,0 +552,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc