comprodls-sdk 2.76.1 → 2.77.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,6 +504,7 @@ 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',
|
|
507
508
|
getPushedEvents: '/accounts/{accountId}/pushed-events/channels'
|
|
508
509
|
};
|
|
509
510
|
|
|
@@ -12827,15 +12828,16 @@ var keepaliveAgent = new Agent({
|
|
|
12827
12828
|
* Public Function definitions
|
|
12828
12829
|
**********************************/
|
|
12829
12830
|
function pushX() {
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12831
|
+
var _pubnubClientWrapper = pubnubClientWrapper();
|
|
12832
|
+
return {
|
|
12833
|
+
"connect": _connect.bind(this, _pubnubClientWrapper),
|
|
12834
|
+
"cleanup": _cleanup.bind(this, _pubnubClientWrapper),
|
|
12835
|
+
"grantByUserOrgId": grantByUserOrgId.bind(this),
|
|
12836
|
+
"grantByAccountId": grantByAccountId.bind(this),
|
|
12837
|
+
"grantByAccountIdOnExtUserId": grantByAccountIdOnExtUserId.bind(this),
|
|
12838
|
+
"grantV2": grantV2.bind(this),
|
|
12839
|
+
"getPushedEvents": getPushedEvents.bind(this)
|
|
12840
|
+
};
|
|
12839
12841
|
}
|
|
12840
12842
|
|
|
12841
12843
|
/*********************************
|
|
@@ -12843,146 +12845,144 @@ function pushX() {
|
|
|
12843
12845
|
**********************************/
|
|
12844
12846
|
|
|
12845
12847
|
function _connect(pubnubCW, options) {
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12848
|
+
var bpubnubV7 = true; // If pubnub v7 or higher in package.json, set it true
|
|
12849
|
+
if (bpubnubV7 && !options.userid) {
|
|
12850
|
+
var err = {};
|
|
12851
|
+
err.message = err.description = 'Mandatory parameter userid not found in request options.';
|
|
12852
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.PUSHX_ERROR, err);
|
|
12853
|
+
throw err;
|
|
12854
|
+
}
|
|
12855
|
+
|
|
12856
|
+
// Adding SSL flag
|
|
12857
|
+
return pubnubCW.setup({
|
|
12858
|
+
'userid': options.userid,
|
|
12859
|
+
'accountid': options.accountid,
|
|
12860
|
+
'token': options.token,
|
|
12861
|
+
'pubnub': {
|
|
12862
|
+
'publishKey': options.publishKey,
|
|
12863
|
+
'subscribeKey': options.subscribeKey,
|
|
12864
|
+
'ssl': true
|
|
12865
|
+
}
|
|
12866
|
+
});
|
|
12865
12867
|
}
|
|
12866
12868
|
|
|
12867
12869
|
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
12868
12870
|
|
|
12869
|
-
/*options = {
|
|
12870
|
-
authKey: <authKey>
|
|
12871
|
-
}*/
|
|
12871
|
+
/*options = {}*/
|
|
12872
12872
|
function grantByUserOrgId(options) {
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
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;
|
|
12873
|
+
var dfd = q.defer(); // Initializing promise
|
|
12874
|
+
var allowedChannels = ['jobs', 'systemevents'];
|
|
12875
|
+
var baseChannelName = "o-" + this.orgId + "\\$u-" + this.token.access_token + "\\$";
|
|
12876
|
+
var patterns = [];
|
|
12877
|
+
for(var i in allowedChannels) {
|
|
12878
|
+
var channelName = baseChannelName + allowedChannels[i] + "\\..*";
|
|
12879
|
+
patterns.push(channelName);
|
|
12880
|
+
}
|
|
12881
|
+
options.channels = {};
|
|
12882
|
+
options.channels.patterns = patterns;
|
|
12883
|
+
grantV2.call(this, options)
|
|
12884
|
+
.then(function (res) {
|
|
12885
|
+
dfd.resolve(res);
|
|
12886
|
+
})
|
|
12887
|
+
.catch(function(err) {
|
|
12888
|
+
dfd.reject(err);
|
|
12889
|
+
});
|
|
12890
|
+
return dfd.promise;
|
|
12906
12891
|
}
|
|
12907
12892
|
|
|
12908
12893
|
/*options = {
|
|
12909
12894
|
accountId: <accountid>,
|
|
12910
|
-
refId: <extRefId
|
|
12911
|
-
authKey: <authKey>
|
|
12895
|
+
refId: <extRefId>
|
|
12912
12896
|
}*/
|
|
12913
12897
|
function grantByAccountId(options) {
|
|
12914
|
-
var
|
|
12915
|
-
|
|
12916
|
-
|
|
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; }
|
|
12898
|
+
var err ={};
|
|
12899
|
+
var dfd = q.defer(); // Initializing promise
|
|
12929
12900
|
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
}
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12901
|
+
if(options.accountId && options.refId) {
|
|
12902
|
+
var channel = "a-" + options.accountId + "$refid." + options.refId;
|
|
12903
|
+
var exactMatch = [channel];
|
|
12904
|
+
options.channels = {};
|
|
12905
|
+
options.channels.exactMatch = exactMatch;
|
|
12906
|
+
grantV2.call(this, options)
|
|
12907
|
+
.then(function (res) {
|
|
12908
|
+
dfd.resolve(res);
|
|
12909
|
+
})
|
|
12910
|
+
.catch(function(err) {
|
|
12911
|
+
dfd.reject(err);
|
|
12912
|
+
});
|
|
12913
|
+
}
|
|
12914
|
+
else {
|
|
12915
|
+
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
12916
|
+
"not found in request options";
|
|
12917
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12918
|
+
dfd.reject(err);
|
|
12919
|
+
}
|
|
12920
|
+
return dfd.promise;
|
|
12946
12921
|
}
|
|
12947
12922
|
|
|
12948
12923
|
/*options = {
|
|
12949
12924
|
accountId: <accountid>,
|
|
12950
12925
|
extUserId: <extUserId>, //mandatory
|
|
12951
|
-
authKey: <authKey>
|
|
12952
12926
|
}*/
|
|
12953
12927
|
function grantByAccountIdOnExtUserId(options) {
|
|
12954
|
-
var
|
|
12955
|
-
|
|
12928
|
+
var err ={};
|
|
12929
|
+
var dfd = q.defer(); // Initializing promise
|
|
12956
12930
|
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12931
|
+
if(options.accountId && options.extUserId) {
|
|
12932
|
+
var channel = "a-" + options.accountId + "$u-" + options.extUserId;
|
|
12933
|
+
var exactMatch = [channel];
|
|
12934
|
+
options.channels = {};
|
|
12935
|
+
options.channels.exactMatch = exactMatch;
|
|
12936
|
+
grantV2.call(this, options)
|
|
12937
|
+
.then(function (res) {
|
|
12938
|
+
dfd.resolve(res);
|
|
12939
|
+
})
|
|
12940
|
+
.catch(function(err) {
|
|
12941
|
+
dfd.reject(err);
|
|
12942
|
+
});
|
|
12943
|
+
}
|
|
12944
|
+
else {
|
|
12945
|
+
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
12946
|
+
"not found in request options";
|
|
12947
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12948
|
+
dfd.reject(err);
|
|
12949
|
+
}
|
|
12950
|
+
return dfd.promise;
|
|
12951
|
+
}
|
|
12966
12952
|
|
|
12967
|
-
|
|
12968
|
-
|
|
12953
|
+
/**
|
|
12954
|
+
* This function provides grant token on given channels
|
|
12955
|
+
* @param { channels: { exactMatch: [], patterns: [] } } options
|
|
12956
|
+
* @returns { token, publishKey, subscribeKey }
|
|
12957
|
+
*/
|
|
12958
|
+
function grantV2(options) {
|
|
12959
|
+
var self = this, err = {};
|
|
12960
|
+
var dfd = q.defer();
|
|
12961
|
+
var body = { channels: {} };
|
|
12962
|
+
if(!options.channels) {
|
|
12963
|
+
err.message = err.description = "channels not given in input body.";
|
|
12964
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12965
|
+
dfd.reject(err);
|
|
12966
|
+
return dfd.promise;
|
|
12967
|
+
}
|
|
12968
|
+
body.channels = options.channels;
|
|
12969
|
+
// Passed all validations, Construct API url
|
|
12970
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantV2;
|
|
12971
|
+
// Setup request with URL and Params
|
|
12972
|
+
var requestAPI = request.post(url)
|
|
12973
|
+
.set('Content-Type', 'application/json')
|
|
12974
|
+
.set('Accept', 'application/json');
|
|
12975
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12969
12976
|
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
}
|
|
12976
|
-
else { dfd.resolve(response.body); }
|
|
12977
|
-
});
|
|
12978
|
-
}
|
|
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);
|
|
12977
|
+
requestAPI.send(body);
|
|
12978
|
+
requestAPI.end(function(err, response) {
|
|
12979
|
+
if(err) {
|
|
12980
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
12981
|
+
dfd.reject(err);
|
|
12984
12982
|
}
|
|
12985
|
-
|
|
12983
|
+
else { dfd.resolve(response.body); }
|
|
12984
|
+
});
|
|
12985
|
+
return dfd.promise;
|
|
12986
12986
|
}
|
|
12987
12987
|
|
|
12988
12988
|
/**
|
|
@@ -13144,8 +13144,10 @@ module.exports = function () {
|
|
|
13144
13144
|
break;
|
|
13145
13145
|
case "PNAccessDeniedCategory":
|
|
13146
13146
|
if(status.operation === "PNSubscribeOperation") {
|
|
13147
|
+
var errorText = status.errorData.response && status.errorData.response.text;
|
|
13148
|
+
var errorJSON = errorText ? JSON.parse(errorText) : undefined;
|
|
13147
13149
|
var errorData = {
|
|
13148
|
-
payload:
|
|
13150
|
+
payload: errorJSON && errorJSON.payload || status.errorData.payload,
|
|
13149
13151
|
message: 'Forbidden: Subscription failed.',
|
|
13150
13152
|
errorDetails: {
|
|
13151
13153
|
operation: status.operation,
|
|
@@ -13249,9 +13251,11 @@ module.exports = function () {
|
|
|
13249
13251
|
var pubnubConfig = userOptions.pubnub;
|
|
13250
13252
|
pubnubConfig.uuid = userOptions.userid;
|
|
13251
13253
|
var accountId = userOptions.accountid;
|
|
13254
|
+
var token = userOptions.token;
|
|
13252
13255
|
|
|
13253
13256
|
if (!_pubnubClient && pubnubConfig) {
|
|
13254
13257
|
_pubnubClient = new pubNub(pubnubConfig); //Connect with PubNub SDK
|
|
13258
|
+
_pubnubClient.setToken(token);
|
|
13255
13259
|
processSetup();
|
|
13256
13260
|
} else {
|
|
13257
13261
|
return new Error('Already Initialized');
|
|
@@ -14292,7 +14296,6 @@ function provisionBulkSpaces(options) {
|
|
|
14292
14296
|
* *startdate: <epoch>,
|
|
14293
14297
|
* *enddate: <epoch>,
|
|
14294
14298
|
* description: 'string',
|
|
14295
|
-
* ext_class_title: 'string',
|
|
14296
14299
|
* ext_data: {},
|
|
14297
14300
|
* limits: {
|
|
14298
14301
|
* *los: 0,
|