Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0c83fb4
pre-requisites for data_sync: handle error array during exceptional c…
May 22, 2026
5502af9
data-sync: channel endpoint apis
May 22, 2026
ea6da83
data-sync:user endpoint apis
May 22, 2026
f128cbc
data-sync:membership endpoint apis
May 22, 2026
fbe3e3c
data-sync: entity endpoint apis
May 22, 2026
8734092
data-sync: entity-relationship endpoint apis
May 22, 2026
1843165
data-sync: apis domain object export, added operation constants, type…
May 22, 2026
7a5a27f
updated dist/lib and codeowner files.
May 22, 2026
e82c07a
fix lint
May 22, 2026
f57123e
Fix CODEOWNERS syntax for jguz-pubnub
mohitpubnub May 22, 2026
3876080
dataSync relationship api for getAll should have class and version in…
May 27, 2026
adbfa29
sync package.json with latest
May 28, 2026
fd1b9e4
fix type definition for getAllRelationships
May 28, 2026
66391b4
Merge branch 'master' into CLEN-3438
mohitpubnub Jun 9, 2026
97152c2
Merge branch 'master' into CLEN-3438
mohitpubnub Jun 25, 2026
4be5002
datasync event handling, grantToken update for datasync permissions
Jul 10, 2026
25eb24d
remove `idempotencyKey` from datasync apis
Jul 21, 2026
f51c1dc
Merge branch 'master' into CLEN-3438
mohitpubnub Jul 21, 2026
6d2d137
lint fixes
Jul 22, 2026
2d6a210
Merge branch 'master' into CLEN-3438
mohitpubnub Jul 23, 2026
c5be680
handling user/channel/membership events in subscription
Jul 23, 2026
8d7f54f
lib files
Jul 23, 2026
7fa7586
dist/lib updates
Jul 23, 2026
2bf1a75
refactor: dataSync apis signature update to improve user experience b…
Jul 27, 2026
0c50646
lint fixes
Jul 27, 2026
82d6083
DATA_SYNC_MODULE environment variable based module load for dataSync …
Jul 27, 2026
be57bd3
Merge branch 'master' into CLEN-3438
mohitpubnub Jul 27, 2026
7e55c5c
dataSync updates: refined method naming convention consistent as per …
mohitpubnub Aug 17, 2026
a35c647
dist and lib files updates
mohitpubnub Aug 17, 2026
25b0586
parseToken to parse users permissions, fix stale test failures of gra…
mohitpubnub Aug 17, 2026
aa34aeb
re-worked update methods added JSDoc for json pointer usage
mohitpubnub Aug 18, 2026
90efcf4
JSDoc with more details on how to use patch (update) apis with json p…
mohitpubnub Aug 19, 2026
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
2,759 changes: 2,689 additions & 70 deletions dist/web/pubnub.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/web/pubnub.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions dist/web/pubnub.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,10 @@
* Request will be sent using `PATCH` method.
*/
TransportMethod["PATCH"] = "PATCH";
/**
* Request will be sent using `PUT` method.
*/
TransportMethod["PUT"] = "PUT";
/**
* Request will be sent using `DELETE` method.
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.worker.min.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions lib/core/components/event-dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ class EventDispatcher {
set onFile(listener) {
this.updateTypeOrObjectListener({ add: !!listener, listener, type: 'file' });
}
/**
* Set a new DataSync event handler.
*
* @param listener - Listener function, which will be called each time when a new
* DataSync event is received from the real-time network.
*/
set onDataSync(listener) {
this.updateTypeOrObjectListener({ add: !!listener, listener, type: 'dataSync' });
}
/**
* Dispatch received a real-time update.
*
Expand Down Expand Up @@ -140,6 +149,8 @@ class EventDispatcher {
this.announce('messageAction', event.data);
else if (event.type === subscribe_1.PubNubEventType.Files)
this.announce('file', event.data);
else if (event.type === subscribe_1.PubNubEventType.DataSync)
this.announce('dataSync', event.data);
}
/**
* Dispatch received connection status change.
Expand Down
4 changes: 3 additions & 1 deletion lib/core/components/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ class AbstractRequest {
if (headers)
request.headers = headers;
// Attach body (if required).
if (request.method === transport_request_1.TransportMethod.POST || request.method === transport_request_1.TransportMethod.PATCH) {
if (request.method === transport_request_1.TransportMethod.POST ||
request.method === transport_request_1.TransportMethod.PATCH ||
request.method === transport_request_1.TransportMethod.PUT) {
const [body, formData] = [this.body, this.formData];
if (formData)
request.formData = formData;
Expand Down
51 changes: 51 additions & 0 deletions lib/core/components/token_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class TokenManager {
* @returns Information about resources and permissions which has been granted for them.
*/
parseToken(tokenString) {
var _a, _b;
const parsed = this.cbor.decodeToken(tokenString);
if (parsed !== undefined) {
const uuidResourcePermissions = parsed.res.uuid ? Object.keys(parsed.res.uuid) : [];
Expand Down Expand Up @@ -80,6 +81,9 @@ class TokenManager {
groupResourcePermissions.forEach((id) => (groups[id] = this.extractPermissions(parsed.res.grp[id])));
}
}
const resourceDataSync = this.extractDataSyncScopes(parsed.res);
if (resourceDataSync)
((_a = result.resources) !== null && _a !== void 0 ? _a : (result.resources = {})).dataSync = resourceDataSync;
const uuidPatterns = uuidPatternPermissions.length > 0;
const channelPatterns = channelPatternPermissions.length > 0;
const groupPatterns = groupPatternPermissions.length > 0;
Expand All @@ -98,6 +102,9 @@ class TokenManager {
groupPatternPermissions.forEach((id) => (groups[id] = this.extractPermissions(parsed.pat.grp[id])));
}
}
const patternDataSync = this.extractDataSyncScopes(parsed.pat);
if (patternDataSync)
((_b = result.patterns) !== null && _b !== void 0 ? _b : (result.patterns = {})).dataSync = patternDataSync;
if (parsed.meta && Object.keys(parsed.meta).length > 0)
result.meta = parsed.meta;
return result;
Expand Down Expand Up @@ -137,5 +144,49 @@ class TokenManager {
permissionsResult.read = true;
return permissionsResult;
}
/**
* Extract DataSync permission scopes from a token permissions section.
*
* The `datasync:*` wire keys are only present for tokens which granted DataSync permissions, so a
* result is returned only when at least one scope carries permissions.
*
* @param section - Raw `res` or `pat` permissions section decoded from the token.
*
* @returns Human-readable DataSync permission scopes, or `undefined` when none are granted.
*/
extractDataSyncScopes(section) {
const dataSyncScopes = [
['entities', 'datasync:entities'],
['relationships', 'datasync:relationships'],
['memberships', 'datasync:memberships'],
];
let result;
dataSyncScopes.forEach(([scope, wireKey]) => {
const permissions = section[wireKey];
if (!permissions)
return;
const ids = Object.keys(permissions);
if (ids.length === 0)
return;
const scopeResult = ((result !== null && result !== void 0 ? result : (result = {}))[scope] = {});
ids.forEach((id) => (scopeResult[id] = this.extractDataSyncPermissions(permissions[id])));
});
return result;
}
/**
* Extract DataSync resource access permission information.
*
* @param permissions - Bit-encoded resource permissions.
*
* @returns Human-readable DataSync resource permissions.
*/
extractDataSyncPermissions(permissions) {
return {
create: (permissions & 16) === 16,
get: (permissions & 32) === 32,
update: (permissions & 64) === 64,
delete: (permissions & 8) === 8,
};
}
}
exports.TokenManager = TokenManager;
123 changes: 123 additions & 0 deletions lib/core/constants/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,129 @@ var RequestOperation;
*/
RequestOperation["PNSetMembershipsOperation"] = "PNSetMembershipsOperation";
// --------------------------------------------------------
// ------------------- DataSync API ----------------------
// --------------------------------------------------------
/**
* Create entity REST API operation.
*/
RequestOperation["PNCreateDataSyncEntityOperation"] = "PNCreateDataSyncEntityOperation";
/**
* Get entity REST API operation.
*/
RequestOperation["PNGetDataSyncEntityOperation"] = "PNGetDataSyncEntityOperation";
/**
* Get all entities REST API operation.
*/
RequestOperation["PNGetDataSyncEntitiesOperation"] = "PNGetDataSyncEntitiesOperation";
/**
* Set entity REST API operation (full replacement via PUT).
*/
RequestOperation["PNSetDataSyncEntityOperation"] = "PNSetDataSyncEntityOperation";
/**
* Update entity REST API operation (partial update via PATCH).
*/
RequestOperation["PNUpdateDataSyncEntityOperation"] = "PNUpdateDataSyncEntityOperation";
/**
* Remove entity REST API operation.
*/
RequestOperation["PNRemoveDataSyncEntityOperation"] = "PNRemoveDataSyncEntityOperation";
/**
* Create relationship REST API operation.
*/
RequestOperation["PNCreateDataSyncRelationshipOperation"] = "PNCreateDataSyncRelationshipOperation";
/**
* Get relationship REST API operation.
*/
RequestOperation["PNGetDataSyncRelationshipOperation"] = "PNGetDataSyncRelationshipOperation";
/**
* Get all relationships REST API operation.
*/
RequestOperation["PNGetDataSyncRelationshipsOperation"] = "PNGetDataSyncRelationshipsOperation";
/**
* Set relationship REST API operation (full replacement via PUT).
*/
RequestOperation["PNSetDataSyncRelationshipOperation"] = "PNSetDataSyncRelationshipOperation";
/**
* Update relationship REST API operation (partial update via PATCH).
*/
RequestOperation["PNUpdateDataSyncRelationshipOperation"] = "PNUpdateDataSyncRelationshipOperation";
/**
* Remove relationship REST API operation.
*/
RequestOperation["PNRemoveDataSyncRelationshipOperation"] = "PNRemoveDataSyncRelationshipOperation";
/**
* Create user REST API operation.
*/
RequestOperation["PNCreateDataSyncUserOperation"] = "PNCreateDataSyncUserOperation";
/**
* Get user REST API operation.
*/
RequestOperation["PNGetDataSyncUserOperation"] = "PNGetDataSyncUserOperation";
/**
* Get all users REST API operation.
*/
RequestOperation["PNGetDataSyncUsersOperation"] = "PNGetDataSyncUsersOperation";
/**
* Set user REST API operation (full replacement via PUT).
*/
RequestOperation["PNSetDataSyncUserOperation"] = "PNSetDataSyncUserOperation";
/**
* Update user REST API operation (partial update via PATCH).
*/
RequestOperation["PNUpdateDataSyncUserOperation"] = "PNUpdateDataSyncUserOperation";
/**
* Remove user REST API operation.
*/
RequestOperation["PNRemoveDataSyncUserOperation"] = "PNRemoveDataSyncUserOperation";
/**
* Create channel REST API operation.
*/
RequestOperation["PNCreateDataSyncChannelOperation"] = "PNCreateDataSyncChannelOperation";
/**
* Get channel REST API operation.
*/
RequestOperation["PNGetDataSyncChannelOperation"] = "PNGetDataSyncChannelOperation";
/**
* Get all channels REST API operation.
*/
RequestOperation["PNGetDataSyncChannelsOperation"] = "PNGetDataSyncChannelsOperation";
/**
* Set channel REST API operation (full replacement via PUT).
*/
RequestOperation["PNSetDataSyncChannelOperation"] = "PNSetDataSyncChannelOperation";
/**
* Update channel REST API operation (partial update via PATCH).
*/
RequestOperation["PNUpdateDataSyncChannelOperation"] = "PNUpdateDataSyncChannelOperation";
/**
* Remove channel REST API operation.
*/
RequestOperation["PNRemoveDataSyncChannelOperation"] = "PNRemoveDataSyncChannelOperation";
/**
* Create membership REST API operation.
*/
RequestOperation["PNCreateDataSyncMembershipOperation"] = "PNCreateDataSyncMembershipOperation";
/**
* Get membership REST API operation.
*/
RequestOperation["PNGetDataSyncMembershipOperation"] = "PNGetDataSyncMembershipOperation";
/**
* Get all memberships REST API operation.
*/
RequestOperation["PNGetDataSyncMembershipsOperation"] = "PNGetDataSyncMembershipsOperation";
/**
* Set membership REST API operation (full replacement via PUT).
*/
RequestOperation["PNSetDataSyncMembershipOperation"] = "PNSetDataSyncMembershipOperation";
/**
* Update membership REST API operation (partial update via PATCH).
*/
RequestOperation["PNUpdateDataSyncMembershipOperation"] = "PNUpdateDataSyncMembershipOperation";
/**
* Remove membership REST API operation.
*/
RequestOperation["PNRemoveDataSyncMembershipOperation"] = "PNRemoveDataSyncMembershipOperation";
// --------------------------------------------------------
// -------------------- File Upload API -------------------
// --------------------------------------------------------
/**
Expand Down
Loading
Loading