Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with string signals #388

Merged
merged 4 commits into from
Jul 4, 2024
Merged
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
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2024-07-04
version: v8.2.5
changes:
- type: bug
text: "Fix issue because of which `signals` sent as `string` not handler properly."
- date: 2024-06-17
version: v8.2.4
changes:
Expand Down Expand Up @@ -1008,7 +1013,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '8.2.4'
version: '8.2.5'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1024,7 +1029,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.2.4.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.2.5.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1695,7 +1700,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v8.2.4/pubnub.8.2.4.js
location: https://github.com/pubnub/javascript/releases/download/v8.2.5/pubnub.8.2.5.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 @@
## v8.2.5
July 04 2024

#### Fixed
- Fix issue because of which `signals` sent as `string` not handler properly. Fixed the following issues reported by [@roman-rr](https://github.com/roman-rr): [#387](https://github.com/pubnub/javascript/issues/387).

## v8.2.4
June 17 2024

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.4.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.4.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.5.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.5.min.js

2. Configure your keys:

Expand Down
4 changes: 2 additions & 2 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -3813,7 +3813,7 @@
return base.PubNubFile;
},
get version() {
return '8.2.4';
return '8.2.5';
},
getVersion() {
return this.version;
Expand Down Expand Up @@ -5870,7 +5870,7 @@
// Resolve missing event type.
eventType !== null && eventType !== void 0 ? eventType : (eventType = envelope.c.endsWith('-pnpres') ? PubNubEventType.Presence : PubNubEventType.Message);
// Check whether payload is string (potentially encrypted data).
if (typeof envelope.d === 'string') {
if (eventType != PubNubEventType.Signal && typeof envelope.d === 'string') {
if (eventType == PubNubEventType.Message) {
return {
type: PubNubEventType.Message,
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/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
return base.PubNubFile;
},
get version() {
return '8.2.4';
return '8.2.5';
},
getVersion() {
return this.version;
Expand Down
2 changes: 1 addition & 1 deletion lib/core/endpoints/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class BaseSubscribeRequest extends request_1.AbstractRequest {
// Resolve missing event type.
eventType !== null && eventType !== void 0 ? eventType : (eventType = envelope.c.endsWith('-pnpres') ? PubNubEventType.Presence : PubNubEventType.Message);
// Check whether payload is string (potentially encrypted data).
if (typeof envelope.d === 'string') {
if (eventType != PubNubEventType.Signal && typeof envelope.d === 'string') {
if (eventType == PubNubEventType.Message) {
return {
type: PubNubEventType.Message,
Expand Down
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": "8.2.4",
"version": "8.2.5",
"author": "PubNub <[email protected]>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const makeConfiguration = (
return base.PubNubFile;
},
get version(): string {
return '8.2.4';
return '8.2.5';
},
getVersion(): string {
return this.version;
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoints/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ export class BaseSubscribeRequest extends AbstractRequest<Subscription.Subscript
eventType ??= envelope.c.endsWith('-pnpres') ? PubNubEventType.Presence : PubNubEventType.Message;

// Check whether payload is string (potentially encrypted data).
if (typeof envelope.d === 'string') {
if (eventType != PubNubEventType.Signal && typeof envelope.d === 'string') {
if (eventType == PubNubEventType.Message) {
return {
type: PubNubEventType.Message,
Expand Down
24 changes: 12 additions & 12 deletions test/integration/components/reconnection_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ describe('#components/reconnection_manger', () => {
pubnub.addListener({
status(statusPayload) {
if (statusPayload.operation !== PubNub.OPERATIONS.PNSubscribeOperation) return;
let statusWithoutError = _.omit(statusPayload, ['errorData', 'statusCode']);
const statusWithoutError = _.omit(statusPayload, ['errorData', 'statusCode']);
try {
assert.deepEqual(
{
category: PubNub.CATEGORIES.PNNetworkIssuesCategory,
error: true,
operation: PubNub.OPERATIONS.PNSubscribeOperation
operation: PubNub.OPERATIONS.PNSubscribeOperation,
},
statusWithoutError
statusWithoutError,
);

utils
.createNock()
.get("/v2/presence/sub-key/mySubKey/channel/ch1,ch2/leave")
.get('/v2/presence/sub-key/mySubKey/channel/ch1,ch2/leave')
.query(true)
.reply(200, "{\"status\": 200, \"message\": \"OK\", \"service\": \"Presence\"}", {
"content-type": "text/javascript"
.reply(200, '{"status": 200, "message": "OK", "service": "Presence"}', {
'content-type': 'text/javascript',
});

done();
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('#components/reconnection_manger', () => {
.query(true)
.reply(
200,
'{"t":{"t":"14607577960932487","r":1},"m":[{"a":"4","f":0,"i":"Client-g5d4g","p":{"t":"14607577960925503","r":1},"k":"sub-c-4cec9f8e-01fa-11e6-8180-0619f8945a4f","c":"coolChannel","d":{"text":"Enter Message Here"},"b":"coolChan-bnel"}]}',
'{"t":{"t":"14607577960932487","r":1},"m":[{"a":"4","f":0,"i":"Client-g5d4g","p":{"t":"14607577960925503","r":1},"k":"mySubKey","c":"coolChannel","d":{"text":"Enter Message Here"},"b":"coolChan-bnel"}]}',
{ 'content-type': 'text/javascript' },
);

Expand All @@ -134,17 +134,17 @@ describe('#components/reconnection_manger', () => {
category: PubNub.CATEGORIES.PNReconnectedCategory,
operation: PubNub.OPERATIONS.PNSubscribeOperation,
currentTimetoken: 0,
lastTimetoken: 0
lastTimetoken: 0,
},
statusPayload
statusPayload,
);

utils
.createNock()
.get("/v2/presence/sub-key/mySubKey/channel/ch1,ch2/leave")
.get('/v2/presence/sub-key/mySubKey/channel/ch1,ch2/leave')
.query(true)
.reply(200, "{\"status\": 200, \"message\": \"OK\", \"service\": \"Presence\"}", {
"content-type": "text/javascript"
.reply(200, '{"status": 200, "message": "OK", "service": "Presence"}', {
'content-type': 'text/javascript',
});

done();
Expand Down
Loading
Loading