Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f7522bf
docs snippets for publish-subscribe, presence, message-persistence, a…
Jun 10, 2025
b88f985
fix: lint issue.
Jun 10, 2025
64ba5f0
removed deprecation from deleteMessages()
Jun 15, 2025
42ba1de
code snippets for documentation. A separate file for impot and initia…
Jun 15, 2025
92af28f
configuration code snippets
Jun 16, 2025
3146b47
script to compile check the code snippets
Jun 16, 2025
c29a021
fix: snippet compilation for lowest node version and build generated …
Jun 16, 2025
83fc584
added missing iterativelyUpdateExistingMetadata
Jun 19, 2025
d2c73db
example with promises syntax demo
Jun 19, 2025
e23870d
missing SubscriptionSet subscribe() basic usage example
Jun 19, 2025
3f03362
added missing subscriptionSet example code snippets
Jun 19, 2025
1e3d2fb
added getFilterExpresssionBasicusage
Jun 23, 2025
d7a28c7
revert changes of providing return type for addSubscriptionSet() meth…
Jun 23, 2025
7e9e949
added getting started code snippets
Jun 23, 2025
5f1cfb3
added missing generic listener syntax example
Jun 23, 2025
ffe1a88
Merge branch 'master' into docs-snippets
mohitpubnub Jun 24, 2025
f97d77f
fix snippets indentation, GrantToken type fix by removing objects syn…
Jun 24, 2025
27519f1
additional information about send file code snippet in node.js
Jun 25, 2025
aab00bd
* address Codacy quality checks suggestions.
Jun 25, 2025
133b270
Codacy suggestions
Jun 25, 2025
772d575
lint: codacy suggestion
Jun 25, 2025
3907c2d
removed deprected warning from deleteMessages API
Jun 25, 2025
8914345
added snippet for connect, disconnect and delete proxy
Jun 26, 2025
a491042
code snippets: formating setToken strings
Jun 26, 2025
9be3a02
fix dummy token length related format issue.
Jun 26, 2025
cdfe082
code snippet: error handling, additional comments
Jun 26, 2025
475b1dd
details about exception in getting started example.
Jun 27, 2025
8ac814d
PubNub SDK v9.6.2 release.
pubnub-release-bot Jun 30, 2025
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
3 changes: 3 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
run: |
npm install
npm run ${{ matrix.env }}
- name: Test docs snippets syntax
if: matrix.node == '18.18.0' && matrix.env == 'ci:node'
run: npm run test:snippets
- name: Cancel workflow runs for commit on error
if: failure()
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
Expand Down
13 changes: 10 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
---
changelog:
- date: 2025-06-30
version: v9.6.2
changes:
- type: improvement
text: "Removed deprecation warning from deleteMessages method."
- type: improvement
text: "Added code snippets for docs."
- date: 2025-06-18
version: v9.6.1
changes:
Expand Down Expand Up @@ -1256,7 +1263,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '9.6.1'
version: '9.6.2'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1272,7 +1279,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v9.6.1.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v9.6.2.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1943,7 +1950,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v9.6.1/pubnub.9.6.1.js
location: https://github.com/pubnub/javascript/releases/download/v9.6.2/pubnub.9.6.2.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v9.6.2
June 30 2025

#### Modified
- Removed deprecation warning from deleteMessages method.
- Added code snippets for docs.

## v9.6.1
June 18 2025

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,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.9.6.1.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.9.6.1.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.9.6.2.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.9.6.2.min.js

2. Configure your keys:

Expand Down
3 changes: 1 addition & 2 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4957,7 +4957,7 @@
return base.PubNubFile;
},
get version() {
return '9.6.1';
return '9.6.2';
},
getVersion() {
return this.version;
Expand Down Expand Up @@ -16170,7 +16170,6 @@
*
* @returns Asynchronous delete messages response or `void` in case if `callback` provided.
*
* @deprecated
*/
deleteMessages(parameters, callback) {
return __awaiter(this, void 0, void 0, function* () {
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions docs-snippets/access-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import PubNub, { PubNubError } from '../lib/types';

const pubnub = new PubNub({
publishKey: 'demo',
subscribeKey: 'demo',
userId: 'myUniqueUserId',
});

// snippet.grantTokenVariousResources
try {
const token = await pubnub.grantToken({
ttl: 15,
authorized_uuid: 'my-authorized-uuid',
resources: {
channels: {
'channel-a': {
read: true,
},
'channel-b': {
read: true,
write: true,
},
'channel-c': {
read: true,
write: true,
},
'channel-d': {
read: true,
write: true,
},
},
groups: {
'channel-group-b': {
read: true,
},
},
uuids: {
'uuid-c': {
get: true,
},
'uuid-d': {
get: true,
update: true,
},
},
},
});
} catch (error) {
console.error(
`Grant token error: ${error}.${
(error as PubNubError).status ? ` Additional information: ${(error as PubNubError).status}` : ''
}`,
);
}
// snippet.end

// snippet.grantTokenUsingRegEx
try {
const token = await pubnub.grantToken({
ttl: 15,
authorized_uuid: 'my-authorized-uuid',
patterns: {
channels: {
'^channel-[A-Za-z0-9]$': {
read: true,
},
},
},
});
} catch (error) {
console.error(
`Grant token error: ${error}.${
(error as PubNubError).status ? ` Additional information: ${(error as PubNubError).status}` : ''
}`,
);
}
// snippet.end

// snippet.grantTokenRegExAndResources
try {
const token = await pubnub.grantToken({
ttl: 15,
authorized_uuid: 'my-authorized-uuid',
resources: {
channels: {
'channel-a': {
read: true,
},
'channel-b': {
read: true,
write: true,
},
'channel-c': {
read: true,
write: true,
},
'channel-d': {
read: true,
write: true,
},
},
groups: {
'channel-group-b': {
read: true,
},
},
uuids: {
'uuid-c': {
get: true,
},
'uuid-d': {
get: true,
update: true,
},
},
},
patterns: {
channels: {
'^channel-[A-Za-z0-9]$': {
read: true,
},
},
},
});
} catch (error) {
console.error(
`Grant token error: ${error}.${
(error as PubNubError).status ? ` Additional information: ${(error as PubNubError).status}` : ''
}`,
);
}
// snippet.end
59 changes: 59 additions & 0 deletions docs-snippets/app-context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import PubNub, { PubNubError } from '../lib/types';

const pubnub = new PubNub({
publishKey: 'demo',
subscribeKey: 'demo',
userId: 'myUniqueUserId',
});

// snippet.iterativelyUpdateExistingMetadata
const channel = 'team.red';
const name = 'Red Team';
const description = 'The channel for Red team.';
const customField = { visible: 'team' };

// Function to set and then update channel metadata
try {
const response = await pubnub.objects.setChannelMetadata({
channel: channel,
data: {
name: name,
description: description,
custom: customField,
},
});
console.log('The channel has been created with name and description.\n');

// Fetch current object with custom fields
const currentObjectResponse = await pubnub.objects.getChannelMetadata({
channel: channel,
include: {
customFields: true,
},
});
const currentObject = currentObjectResponse.data;

// Initialize the custom field object
const custom = currentObject.custom || {};

// Add or update the field
custom['edit'] = 'admin';

// Writing the updated object back to the server
const setResponse = await pubnub.objects.setChannelMetadata({
channel: channel,
data: {
name: currentObject.name || '',
description: currentObject.description || '',
custom: custom,
},
});
console.log('Object has been updated', setResponse);
} catch (error) {
console.error(
`Set channel metadata error: ${error}.${
(error as PubNubError).status ? ` Additional information: ${(error as PubNubError).status}` : ''
}`,
);
}
// snippet.end
52 changes: 52 additions & 0 deletions docs-snippets/basic-usage/access-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import PubNub, { PubNubError } from '../../lib/types';

const pubnub = new PubNub({
publishKey: 'demo',
subscribeKey: 'demo',
userId: 'myUniqueUserId',
});

// snippet.accessManagerBasicUsage
// Function to use grantToken method
try {
const token = await pubnub.grantToken({
ttl: 15,
authorized_uuid: 'my-authorized-uuid',
resources: {
channels: {
'my-channel': {
read: true,
write: true,
},
},
},
});
console.log('Granted Token:', token);
} catch (error) {
console.error(
`Grant token error: ${error}.${
(error as PubNubError).status ? ` Additional information: ${(error as PubNubError).status}` : ''
}`,
);
}
// snippet.end

// snippet.revokeTokenBasicUsage
try {
const response = await pubnub.revokeToken('p0AkFl043rhDdHRsple3KgQ3NwY6BDcENnctokenVzcqBDczaWdYIGOAeTyWGJI');
} catch (error) {
console.error(
`Revoke token error: ${error}.${
(error as PubNubError).status ? ` Additional information: ${(error as PubNubError).status}` : ''
}`,
);
}
// snippet.end

// snippet.parseTokenBasicUsage
pubnub.parseToken('use-token-string-generated-by-grantToken()');
// snippet.end

// snippet.setTokenBasicUsage
pubnub.setToken('use-token-string-generated-by-grantToken()');
// snippet.end
Loading
Loading