comprodls-sdk 2.76.1 → 2.77.1
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 +135 -136
- package/dist/comprodls-sdk.min.js +1 -1
- package/lib/config/index.js +1 -0
- package/lib/helpers/lib/errors.js +1 -3
- package/lib/services/pushX/index.js +128 -129
- package/lib/services/pushX/pubnubClientWrapper.js +8 -6
- package/lib/services/spaces/index.js +0 -1
- package/package.json +1 -1
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
|
|
|
@@ -922,9 +923,7 @@ function validateGenericAPICaller(apiName, method, url, params) {
|
|
|
922
923
|
var ERROR_TYPES = {
|
|
923
924
|
"API_ERROR": "API_ERROR",
|
|
924
925
|
"SDK_ERROR": "SDK_ERROR",
|
|
925
|
-
"CHANNEL_SUBSCRIPTION": "CHANNEL_SUBSCRIPTION"
|
|
926
|
-
"UNEXPECTED_ERROR": "UNEXPECTED_ERROR",
|
|
927
|
-
"POLLING_INITIATION": "POLLING_INITIATION"
|
|
926
|
+
"CHANNEL_SUBSCRIPTION": "CHANNEL_SUBSCRIPTION"
|
|
928
927
|
};
|
|
929
928
|
|
|
930
929
|
var ERROR_CATEGORY = {
|
|
@@ -12827,15 +12826,16 @@ var keepaliveAgent = new Agent({
|
|
|
12827
12826
|
* Public Function definitions
|
|
12828
12827
|
**********************************/
|
|
12829
12828
|
function pushX() {
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12829
|
+
var _pubnubClientWrapper = pubnubClientWrapper();
|
|
12830
|
+
return {
|
|
12831
|
+
"connect": _connect.bind(this, _pubnubClientWrapper),
|
|
12832
|
+
"cleanup": _cleanup.bind(this, _pubnubClientWrapper),
|
|
12833
|
+
"grantByUserOrgId": grantByUserOrgId.bind(this),
|
|
12834
|
+
"grantByAccountId": grantByAccountId.bind(this),
|
|
12835
|
+
"grantByAccountIdOnExtUserId": grantByAccountIdOnExtUserId.bind(this),
|
|
12836
|
+
"grantV2": grantV2.bind(this),
|
|
12837
|
+
"getPushedEvents": getPushedEvents.bind(this)
|
|
12838
|
+
};
|
|
12839
12839
|
}
|
|
12840
12840
|
|
|
12841
12841
|
/*********************************
|
|
@@ -12843,146 +12843,144 @@ function pushX() {
|
|
|
12843
12843
|
**********************************/
|
|
12844
12844
|
|
|
12845
12845
|
function _connect(pubnubCW, options) {
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
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
|
+
'token': options.token,
|
|
12859
|
+
'pubnub': {
|
|
12860
|
+
'publishKey': options.publishKey,
|
|
12861
|
+
'subscribeKey': options.subscribeKey,
|
|
12862
|
+
'ssl': true
|
|
12863
|
+
}
|
|
12864
|
+
});
|
|
12865
12865
|
}
|
|
12866
12866
|
|
|
12867
12867
|
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
12868
12868
|
|
|
12869
|
-
/*options = {
|
|
12870
|
-
authKey: <authKey>
|
|
12871
|
-
}*/
|
|
12869
|
+
/*options = {}*/
|
|
12872
12870
|
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;
|
|
12871
|
+
var dfd = q.defer(); // Initializing promise
|
|
12872
|
+
var allowedChannels = ['jobs', 'systemevents'];
|
|
12873
|
+
var baseChannelName = "o-" + this.orgId + "\\$u-" + this.token.access_token + "\\$";
|
|
12874
|
+
var patterns = [];
|
|
12875
|
+
for(var i in allowedChannels) {
|
|
12876
|
+
var channelName = baseChannelName + allowedChannels[i] + "\\..*";
|
|
12877
|
+
patterns.push(channelName);
|
|
12878
|
+
}
|
|
12879
|
+
options.channels = {};
|
|
12880
|
+
options.channels.patterns = patterns;
|
|
12881
|
+
grantV2.call(this, options)
|
|
12882
|
+
.then(function (res) {
|
|
12883
|
+
dfd.resolve(res);
|
|
12884
|
+
})
|
|
12885
|
+
.catch(function(err) {
|
|
12886
|
+
dfd.reject(err);
|
|
12887
|
+
});
|
|
12888
|
+
return dfd.promise;
|
|
12906
12889
|
}
|
|
12907
12890
|
|
|
12908
12891
|
/*options = {
|
|
12909
12892
|
accountId: <accountid>,
|
|
12910
|
-
refId: <extRefId
|
|
12911
|
-
authKey: <authKey>
|
|
12893
|
+
refId: <extRefId>
|
|
12912
12894
|
}*/
|
|
12913
12895
|
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; }
|
|
12896
|
+
var err ={};
|
|
12897
|
+
var dfd = q.defer(); // Initializing promise
|
|
12929
12898
|
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
}
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12899
|
+
if(options.accountId && options.refId) {
|
|
12900
|
+
var channel = "a-" + options.accountId + "$refid." + options.refId;
|
|
12901
|
+
var exactMatch = [channel];
|
|
12902
|
+
options.channels = {};
|
|
12903
|
+
options.channels.exactMatch = exactMatch;
|
|
12904
|
+
grantV2.call(this, options)
|
|
12905
|
+
.then(function (res) {
|
|
12906
|
+
dfd.resolve(res);
|
|
12907
|
+
})
|
|
12908
|
+
.catch(function(err) {
|
|
12909
|
+
dfd.reject(err);
|
|
12910
|
+
});
|
|
12911
|
+
}
|
|
12912
|
+
else {
|
|
12913
|
+
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
12914
|
+
"not found in request options";
|
|
12915
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12916
|
+
dfd.reject(err);
|
|
12917
|
+
}
|
|
12918
|
+
return dfd.promise;
|
|
12946
12919
|
}
|
|
12947
12920
|
|
|
12948
12921
|
/*options = {
|
|
12949
12922
|
accountId: <accountid>,
|
|
12950
12923
|
extUserId: <extUserId>, //mandatory
|
|
12951
|
-
authKey: <authKey>
|
|
12952
12924
|
}*/
|
|
12953
12925
|
function grantByAccountIdOnExtUserId(options) {
|
|
12954
|
-
var
|
|
12955
|
-
|
|
12926
|
+
var err ={};
|
|
12927
|
+
var dfd = q.defer(); // Initializing promise
|
|
12956
12928
|
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12929
|
+
if(options.accountId && options.extUserId) {
|
|
12930
|
+
var channel = "a-" + options.accountId + "$u-" + options.extUserId;
|
|
12931
|
+
var exactMatch = [channel];
|
|
12932
|
+
options.channels = {};
|
|
12933
|
+
options.channels.exactMatch = exactMatch;
|
|
12934
|
+
grantV2.call(this, options)
|
|
12935
|
+
.then(function (res) {
|
|
12936
|
+
dfd.resolve(res);
|
|
12937
|
+
})
|
|
12938
|
+
.catch(function(err) {
|
|
12939
|
+
dfd.reject(err);
|
|
12940
|
+
});
|
|
12941
|
+
}
|
|
12942
|
+
else {
|
|
12943
|
+
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
12944
|
+
"not found in request options";
|
|
12945
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12946
|
+
dfd.reject(err);
|
|
12947
|
+
}
|
|
12948
|
+
return dfd.promise;
|
|
12949
|
+
}
|
|
12966
12950
|
|
|
12967
|
-
|
|
12968
|
-
|
|
12951
|
+
/**
|
|
12952
|
+
* This function provides grant token on given channels
|
|
12953
|
+
* @param { channels: { exactMatch: [], patterns: [] } } options
|
|
12954
|
+
* @returns { token, publishKey, subscribeKey }
|
|
12955
|
+
*/
|
|
12956
|
+
function grantV2(options) {
|
|
12957
|
+
var self = this, err = {};
|
|
12958
|
+
var dfd = q.defer();
|
|
12959
|
+
var body = { channels: {} };
|
|
12960
|
+
if(!options.channels) {
|
|
12961
|
+
err.message = err.description = "channels not given in input body.";
|
|
12962
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12963
|
+
dfd.reject(err);
|
|
12964
|
+
return dfd.promise;
|
|
12965
|
+
}
|
|
12966
|
+
body.channels = options.channels;
|
|
12967
|
+
// Passed all validations, Construct API url
|
|
12968
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantV2;
|
|
12969
|
+
// Setup request with URL and Params
|
|
12970
|
+
var requestAPI = request.post(url)
|
|
12971
|
+
.set('Content-Type', 'application/json')
|
|
12972
|
+
.set('Accept', 'application/json');
|
|
12973
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12969
12974
|
|
|
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);
|
|
12975
|
+
requestAPI.send(body);
|
|
12976
|
+
requestAPI.end(function(err, response) {
|
|
12977
|
+
if(err) {
|
|
12978
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
12979
|
+
dfd.reject(err);
|
|
12984
12980
|
}
|
|
12985
|
-
|
|
12981
|
+
else { dfd.resolve(response.body); }
|
|
12982
|
+
});
|
|
12983
|
+
return dfd.promise;
|
|
12986
12984
|
}
|
|
12987
12985
|
|
|
12988
12986
|
/**
|
|
@@ -13144,8 +13142,10 @@ module.exports = function () {
|
|
|
13144
13142
|
break;
|
|
13145
13143
|
case "PNAccessDeniedCategory":
|
|
13146
13144
|
if(status.operation === "PNSubscribeOperation") {
|
|
13145
|
+
var errorText = status.errorData.response && status.errorData.response.text;
|
|
13146
|
+
var errorJSON = errorText ? JSON.parse(errorText) : undefined;
|
|
13147
13147
|
var errorData = {
|
|
13148
|
-
payload:
|
|
13148
|
+
payload: errorJSON && errorJSON.payload || status.errorData.payload,
|
|
13149
13149
|
message: 'Forbidden: Subscription failed.',
|
|
13150
13150
|
errorDetails: {
|
|
13151
13151
|
operation: status.operation,
|
|
@@ -13178,9 +13178,8 @@ module.exports = function () {
|
|
|
13178
13178
|
if(status.operation === 'PNSubscribeOperation') {
|
|
13179
13179
|
if(!options.accountId) {
|
|
13180
13180
|
error = {
|
|
13181
|
-
message: "Missing mandatory parameters to initiate polling operation - accountId",
|
|
13182
|
-
status: status.statusCode
|
|
13183
|
-
type: helpers.errors.ERROR_TYPES.POLLING_INITIATION,
|
|
13181
|
+
message: "Polling initiation error: Missing mandatory parameters to initiate polling operation - accountId",
|
|
13182
|
+
status: status.statusCode
|
|
13184
13183
|
};
|
|
13185
13184
|
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
13186
13185
|
_eventEmitter.emit('pushx_status', error);
|
|
@@ -13207,9 +13206,8 @@ module.exports = function () {
|
|
|
13207
13206
|
default:
|
|
13208
13207
|
// Emit error for other status-category received from pubnub
|
|
13209
13208
|
error = {
|
|
13210
|
-
message: "PushX Error",
|
|
13209
|
+
message: "PushX Error: unexpected error",
|
|
13211
13210
|
status: status.statusCode,
|
|
13212
|
-
type: helpers.errors.ERROR_TYPES.UNEXPECTED_ERROR,
|
|
13213
13211
|
pushXError: status
|
|
13214
13212
|
};
|
|
13215
13213
|
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
@@ -13249,9 +13247,11 @@ module.exports = function () {
|
|
|
13249
13247
|
var pubnubConfig = userOptions.pubnub;
|
|
13250
13248
|
pubnubConfig.uuid = userOptions.userid;
|
|
13251
13249
|
var accountId = userOptions.accountid;
|
|
13250
|
+
var token = userOptions.token;
|
|
13252
13251
|
|
|
13253
13252
|
if (!_pubnubClient && pubnubConfig) {
|
|
13254
13253
|
_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');
|
|
@@ -14292,7 +14292,6 @@ function provisionBulkSpaces(options) {
|
|
|
14292
14292
|
* *startdate: <epoch>,
|
|
14293
14293
|
* *enddate: <epoch>,
|
|
14294
14294
|
* description: 'string',
|
|
14295
|
-
* ext_class_title: 'string',
|
|
14296
14295
|
* ext_data: {},
|
|
14297
14296
|
* limits: {
|
|
14298
14297
|
* *los: 0,
|