comprodls-sdk 2.75.0 → 2.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/comprodls-sdk.js
CHANGED
|
@@ -504,7 +504,6 @@ exports.PUB_API_URLS = {
|
|
|
504
504
|
exports.PUSHX_API_URLS = {
|
|
505
505
|
grantByUserOrgId: '/orgs/{orgId}/grants',
|
|
506
506
|
grantByAccountId: '/accounts/{accountId}/grants',
|
|
507
|
-
grantV2: '/ver/v2/grants',
|
|
508
507
|
getPushedEvents: '/accounts/{accountId}/pushed-events/channels'
|
|
509
508
|
};
|
|
510
509
|
|
|
@@ -12828,16 +12827,15 @@ var keepaliveAgent = new Agent({
|
|
|
12828
12827
|
* Public Function definitions
|
|
12829
12828
|
**********************************/
|
|
12830
12829
|
function pushX() {
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
};
|
|
12830
|
+
var _pubnubClientWrapper = pubnubClientWrapper();
|
|
12831
|
+
return {
|
|
12832
|
+
"connect": _connect.bind(this, _pubnubClientWrapper),
|
|
12833
|
+
"cleanup": _cleanup.bind(this, _pubnubClientWrapper),
|
|
12834
|
+
"grantByUserOrgId": grantByUserOrgId.bind(this),
|
|
12835
|
+
"grantByAccountId": grantByAccountId.bind(this),
|
|
12836
|
+
"grantByAccountIdOnExtUserId": grantByAccountIdOnExtUserId.bind(this),
|
|
12837
|
+
"getPushedEvents": getPushedEvents.bind(this)
|
|
12838
|
+
};
|
|
12841
12839
|
}
|
|
12842
12840
|
|
|
12843
12841
|
/*********************************
|
|
@@ -12845,146 +12843,146 @@ function pushX() {
|
|
|
12845
12843
|
**********************************/
|
|
12846
12844
|
|
|
12847
12845
|
function _connect(pubnubCW, options) {
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12846
|
+
var bpubnubV7 = true; // If pubnub v7 or higher in package.json, set it true
|
|
12847
|
+
if (bpubnubV7 && !options.userid) {
|
|
12848
|
+
var err = {};
|
|
12849
|
+
err.message = err.description = 'Mandatory parameter userid not found in request options.';
|
|
12850
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.PUSHX_ERROR, err);
|
|
12851
|
+
throw err;
|
|
12852
|
+
}
|
|
12853
|
+
|
|
12854
|
+
// Adding SSL flag
|
|
12855
|
+
return pubnubCW.setup({
|
|
12856
|
+
'userid': options.userid,
|
|
12857
|
+
'accountid': options.accountid,
|
|
12858
|
+
'pubnub': {
|
|
12859
|
+
'publishKey': options.publishKey,
|
|
12860
|
+
'subscribeKey': options.subscribeKey,
|
|
12861
|
+
'authKey': options.authKey,
|
|
12862
|
+
'ssl': true
|
|
12863
|
+
}
|
|
12864
|
+
});
|
|
12867
12865
|
}
|
|
12868
12866
|
|
|
12869
12867
|
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
12870
12868
|
|
|
12871
12869
|
/*options = {
|
|
12872
|
-
|
|
12870
|
+
authKey: <authKey>
|
|
12873
12871
|
}*/
|
|
12874
12872
|
function grantByUserOrgId(options) {
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12873
|
+
var self = this;
|
|
12874
|
+
var dfd = q.defer(); // Initializing promise
|
|
12875
|
+
// Validations
|
|
12876
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
12877
|
+
if(err) { dfd.reject(err); }
|
|
12878
|
+
else {
|
|
12879
|
+
// Passed all validations, Construct API url
|
|
12880
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByUserOrgId;
|
|
12881
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
12882
|
+
// Setup request with URL and Params
|
|
12883
|
+
var requestAPI = request.post(url)
|
|
12884
|
+
.set('Content-Type', 'application/json')
|
|
12885
|
+
.set('Accept', 'application/json');
|
|
12886
|
+
|
|
12887
|
+
var body = {};
|
|
12888
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
12889
|
+
|
|
12890
|
+
requestAPI.send(body);
|
|
12891
|
+
|
|
12892
|
+
//Setup token in Authorization header
|
|
12893
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
12894
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12895
|
+
|
|
12896
|
+
// Call Change Password Api
|
|
12897
|
+
requestAPI.end(function(err, response) {
|
|
12898
|
+
if(err) {
|
|
12899
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
12900
|
+
dfd.reject(err);
|
|
12901
|
+
}
|
|
12902
|
+
else { dfd.resolve(response.body); }
|
|
12903
|
+
});
|
|
12904
|
+
}
|
|
12905
|
+
return dfd.promise;
|
|
12893
12906
|
}
|
|
12894
12907
|
|
|
12895
12908
|
/*options = {
|
|
12896
12909
|
accountId: <accountid>,
|
|
12897
|
-
refId: <extRefId
|
|
12910
|
+
refId: <extRefId>,
|
|
12911
|
+
authKey: <authKey>
|
|
12898
12912
|
}*/
|
|
12899
12913
|
function grantByAccountId(options) {
|
|
12900
|
-
var err ={};
|
|
12901
|
-
|
|
12914
|
+
var self = this, err ={};
|
|
12915
|
+
var dfd = q.defer(); // Initializing promise
|
|
12902
12916
|
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12917
|
+
if(options.accountId && options.refId) {
|
|
12918
|
+
// Passed all validations, Construct API url
|
|
12919
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
12920
|
+
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
12921
|
+
// Setup request with URL and Params
|
|
12922
|
+
var requestAPI = request.post(url)
|
|
12923
|
+
.set('Content-Type', 'application/json')
|
|
12924
|
+
.set('Accept', 'application/json');
|
|
12925
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12926
|
+
|
|
12927
|
+
var body = { refId: options.refId };
|
|
12928
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
12929
|
+
|
|
12930
|
+
requestAPI.send(body);
|
|
12931
|
+
requestAPI.end(function(err, response) {
|
|
12932
|
+
if(err) {
|
|
12933
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
12934
|
+
dfd.reject(err);
|
|
12935
|
+
}
|
|
12936
|
+
else { dfd.resolve(response.body); }
|
|
12937
|
+
});
|
|
12938
|
+
}
|
|
12939
|
+
else {
|
|
12940
|
+
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
12941
|
+
"not found in request options";
|
|
12942
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12943
|
+
dfd.reject(err);
|
|
12944
|
+
}
|
|
12945
|
+
return dfd.promise;
|
|
12923
12946
|
}
|
|
12924
12947
|
|
|
12925
12948
|
/*options = {
|
|
12926
12949
|
accountId: <accountid>,
|
|
12927
12950
|
extUserId: <extUserId>, //mandatory
|
|
12951
|
+
authKey: <authKey>
|
|
12928
12952
|
}*/
|
|
12929
12953
|
function grantByAccountIdOnExtUserId(options) {
|
|
12930
|
-
var err ={};
|
|
12931
|
-
|
|
12954
|
+
var self = this, err ={};
|
|
12955
|
+
var dfd = q.defer(); // Initializing promise
|
|
12932
12956
|
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
.catch(function(err) {
|
|
12943
|
-
dfd.reject(err);
|
|
12944
|
-
});
|
|
12945
|
-
}
|
|
12946
|
-
else {
|
|
12947
|
-
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
12948
|
-
"not found in request options";
|
|
12949
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12950
|
-
dfd.reject(err);
|
|
12951
|
-
}
|
|
12952
|
-
return dfd.promise;
|
|
12953
|
-
}
|
|
12957
|
+
if(options.accountId && options.extUserId) {
|
|
12958
|
+
// Passed all validations, Construct API url
|
|
12959
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
12960
|
+
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
12961
|
+
// Setup request with URL and Params
|
|
12962
|
+
var requestAPI = request.post(url)
|
|
12963
|
+
.set('Content-Type', 'application/json')
|
|
12964
|
+
.set('Accept', 'application/json');
|
|
12965
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12954
12966
|
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
* @param { channels: { exactMatch: [], patterns: [] } } options
|
|
12958
|
-
* @returns { token, publishKey, subscribeKey }
|
|
12959
|
-
*/
|
|
12960
|
-
function grantV2(options) {
|
|
12961
|
-
var self = this, err = {};
|
|
12962
|
-
var dfd = q.defer();
|
|
12963
|
-
var body = { channels: {} };
|
|
12964
|
-
if(!options.channels) {
|
|
12965
|
-
err.message = err.description = "channels not given in input body.";
|
|
12966
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12967
|
-
dfd.reject(err);
|
|
12968
|
-
return dfd.promise;
|
|
12969
|
-
}
|
|
12970
|
-
body.channels = options.channels;
|
|
12971
|
-
// Passed all validations, Construct API url
|
|
12972
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantV2;
|
|
12973
|
-
// Setup request with URL and Params
|
|
12974
|
-
var requestAPI = request.post(url)
|
|
12975
|
-
.set('Content-Type', 'application/json')
|
|
12976
|
-
.set('Accept', 'application/json');
|
|
12977
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12967
|
+
var body = { extUserId: options.extUserId };
|
|
12968
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
12978
12969
|
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12970
|
+
requestAPI.send(body);
|
|
12971
|
+
requestAPI.end(function(err, response) {
|
|
12972
|
+
if(err) {
|
|
12973
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
12974
|
+
dfd.reject(err);
|
|
12975
|
+
}
|
|
12976
|
+
else { dfd.resolve(response.body); }
|
|
12977
|
+
});
|
|
12984
12978
|
}
|
|
12985
|
-
else {
|
|
12986
|
-
|
|
12987
|
-
|
|
12979
|
+
else {
|
|
12980
|
+
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
12981
|
+
"not found in request options";
|
|
12982
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12983
|
+
dfd.reject(err);
|
|
12984
|
+
}
|
|
12985
|
+
return dfd.promise;
|
|
12988
12986
|
}
|
|
12989
12987
|
|
|
12990
12988
|
/**
|
|
@@ -13058,6 +13056,7 @@ module.exports = function () {
|
|
|
13058
13056
|
var _globalSubscription = [];
|
|
13059
13057
|
var _globalSubscriptionStatus = {};
|
|
13060
13058
|
var bStatusSubscribed = false;
|
|
13059
|
+
var bPollingInitiated = false;
|
|
13061
13060
|
|
|
13062
13061
|
/** ###### END OF MODULE GLOBALS */
|
|
13063
13062
|
|
|
@@ -13091,7 +13090,8 @@ module.exports = function () {
|
|
|
13091
13090
|
if(!_globalSubscription.includes(pubNubChannel)) {
|
|
13092
13091
|
_globalSubscription.push(pubNubChannel);
|
|
13093
13092
|
_globalSubscriptionStatus[pubNubChannel] = {
|
|
13094
|
-
status: 'pending'
|
|
13093
|
+
status: 'pending',
|
|
13094
|
+
pushedEventIdentifier: pubNubChannel.split('.*')[0]
|
|
13095
13095
|
};
|
|
13096
13096
|
_eventEmitter.on(pubNubChannel, handler);
|
|
13097
13097
|
_subscribeToPubNubChannels(pubNubChannel);
|
|
@@ -13140,11 +13140,10 @@ module.exports = function () {
|
|
|
13140
13140
|
}
|
|
13141
13141
|
break;
|
|
13142
13142
|
case "PNAccessDeniedCategory":
|
|
13143
|
+
if(bPollingInitiated) break;
|
|
13143
13144
|
if(status.operation === "PNSubscribeOperation") {
|
|
13144
|
-
var errorText = status.errorData.response && status.errorData.response.text;
|
|
13145
|
-
var errorJSON = errorText ? JSON.parse(errorText) : undefined;
|
|
13146
13145
|
var errorData = {
|
|
13147
|
-
payload:
|
|
13146
|
+
payload: JSON.parse(status.errorData.response.text).payload,
|
|
13148
13147
|
message: 'Forbidden: Subscription failed.',
|
|
13149
13148
|
errorDetails: {
|
|
13150
13149
|
operation: status.operation,
|
|
@@ -13166,6 +13165,7 @@ module.exports = function () {
|
|
|
13166
13165
|
case "PNBadRequestCategory":
|
|
13167
13166
|
case "PNNetworkDownCategory":
|
|
13168
13167
|
case "PNNetworkUpCategory":
|
|
13168
|
+
if(bPollingInitiated) break;
|
|
13169
13169
|
error = {
|
|
13170
13170
|
message: "PushX Error", status: status.statusCode,
|
|
13171
13171
|
pushXError: status
|
|
@@ -13193,6 +13193,7 @@ module.exports = function () {
|
|
|
13193
13193
|
* The wrapper supports multiple channels, but the APP currently uses a single channel only.
|
|
13194
13194
|
* Polling will also limited to a single channel.
|
|
13195
13195
|
*/
|
|
13196
|
+
bPollingInitiated = true;
|
|
13196
13197
|
}
|
|
13197
13198
|
}
|
|
13198
13199
|
else {
|
|
@@ -13203,6 +13204,7 @@ module.exports = function () {
|
|
|
13203
13204
|
// Handle reconnected category status.
|
|
13204
13205
|
break;
|
|
13205
13206
|
default:
|
|
13207
|
+
if(bPollingInitiated) break;
|
|
13206
13208
|
// Emit error for other status-category received from pubnub
|
|
13207
13209
|
error = {
|
|
13208
13210
|
message: "PushX Error",
|
|
@@ -13247,11 +13249,9 @@ module.exports = function () {
|
|
|
13247
13249
|
var pubnubConfig = userOptions.pubnub;
|
|
13248
13250
|
pubnubConfig.uuid = userOptions.userid;
|
|
13249
13251
|
var accountId = userOptions.accountid;
|
|
13250
|
-
var token = userOptions.token;
|
|
13251
13252
|
|
|
13252
13253
|
if (!_pubnubClient && pubnubConfig) {
|
|
13253
13254
|
_pubnubClient = new pubNub(pubnubConfig); //Connect with PubNub SDK
|
|
13254
|
-
_pubnubClient.setToken(token);
|
|
13255
13255
|
processSetup();
|
|
13256
13256
|
} else {
|
|
13257
13257
|
return new Error('Already Initialized');
|
|
@@ -14291,6 +14291,7 @@ function provisionBulkSpaces(options) {
|
|
|
14291
14291
|
* *startdate: <epoch>,
|
|
14292
14292
|
* *enddate: <epoch>,
|
|
14293
14293
|
* description: 'string',
|
|
14294
|
+
* ext_class_title: 'string',
|
|
14294
14295
|
* ext_data: {},
|
|
14295
14296
|
* limits: {
|
|
14296
14297
|
* *los: 0,
|