comprodls-sdk 2.123.2-security → 2.123.4-oidc-poc.2

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.
Files changed (36) hide show
  1. package/.eslintrc +28 -28
  2. package/.github/workflows/npm-publish.yml +76 -0
  3. package/README.md +235 -235
  4. package/dist/comprodls-sdk.js +13543 -13543
  5. package/docs/npm-oidc-publishing-runbook.md +229 -0
  6. package/lib/comprodls.js +132 -132
  7. package/lib/config/index.js +356 -356
  8. package/lib/helpers/index.js +31 -31
  9. package/lib/helpers/lib/api/converter.js +129 -129
  10. package/lib/helpers/lib/api/index.js +46 -46
  11. package/lib/helpers/lib/errors.js +122 -122
  12. package/lib/helpers/lib/requestLayer.js +154 -154
  13. package/lib/helpers/lib/validator.js +192 -192
  14. package/lib/open_access/index.js +116 -116
  15. package/lib/services/analytics/index.js +1365 -1365
  16. package/lib/services/attempts/index.js +389 -389
  17. package/lib/services/auth/index.js +3708 -3708
  18. package/lib/services/authextn/index.js +1032 -1032
  19. package/lib/services/datasyncmanager/index.js +275 -275
  20. package/lib/services/drive/index.js +270 -270
  21. package/lib/services/integrations/index.js +525 -525
  22. package/lib/services/invitations/index.js +282 -282
  23. package/lib/services/product/index.js +343 -343
  24. package/lib/services/pub/index.js +530 -530
  25. package/lib/services/pushX/index.js +251 -251
  26. package/lib/services/pushX/pubnubClientWrapper.js +438 -438
  27. package/lib/services/rules/index.js +416 -416
  28. package/lib/services/spaces/index.js +999 -999
  29. package/lib/services/spacesextn/index.js +131 -131
  30. package/lib/services/superuser/index.js +160 -160
  31. package/lib/services/taxonomy/index.js +405 -405
  32. package/lib/services/workflows/index.js +406 -406
  33. package/lib/services/xapi/index.js +114 -114
  34. package/lib/token/index.js +120 -120
  35. package/lib/token/validations.js +85 -85
  36. package/package.json +5 -1
@@ -1,192 +1,192 @@
1
- /*************************************************************************
2
- *
3
- * COMPRO CONFIDENTIAL
4
- * __________________
5
- *
6
- * [2015] - [2020] Compro Technologies Private Limited
7
- * All Rights Reserved.
8
- *
9
- * NOTICE: All information contained herein is, and remains
10
- * the property of Compro Technologies Private Limited. The
11
- * intellectual and technical concepts contained herein are
12
- * proprietary to Compro Technologies Private Limited and may
13
- * be covered by U.S. and Foreign Patents, patents in process,
14
- * and are protected by trade secret or copyright law.
15
- *
16
- * Dissemination of this information or reproduction of this material
17
- * is strictly forbidden unless prior written permission is obtained
18
- * from Compro Technologies Pvt. Ltd..
19
- ***************************************************************************/
20
-
21
- /***********************************************************
22
- * comproDLS SDK Validator Helper Module
23
- * This module contains validation helper functions for comproDLS SDK
24
- ************************************************************/
25
-
26
- var errors = require('./errors');
27
- var DLSError = errors.DLSError;
28
-
29
- /*********************************
30
- * Core validator utilities
31
- * Each validator follows the signature:
32
- * fn(field, value, options) → DLSError | undefined
33
- *
34
- * - field : the constraint key name e.g. 'organization', 'token', 'token.access_token'
35
- * - value : the value from the options object for that field
36
- * - options : the rule config, can be `true` or `{ message: '...' }`
37
- * For `contains`, options is a string or array of required keys.
38
- *
39
- * Returning a DLSError which stops validation immediately.
40
- * Returning undefined means the check passed.
41
- **********************************/
42
- var validators = {
43
- /**
44
- * Fails if value is null, undefined, or blank/whitespace-only string or empty object.
45
- */
46
- presence: function(field, value, options) {
47
- if (value === undefined || value === null || value === '' ||
48
- (typeof value == 'string' && value.trim() === '') ||
49
- (typeof value == 'object' && Object.keys(value).length === 0)
50
- ) {
51
- return createError(options.message || field + ' can\'t be blank');
52
- }
53
- },
54
-
55
- /**
56
- * Fails if value is not a string.
57
- */
58
- isString: function(field, value, options) {
59
- if (typeof value !== 'string') {
60
- return createError(options.message || field + ' is not a valid string');
61
- }
62
- },
63
-
64
- /**
65
- * Fails if value is not an object.
66
- */
67
- isObject: function(field, value, options) {
68
- if (typeof value !== 'object' || Array.isArray(value)) {
69
- return createError(options.message || field + ' is not a valid object');
70
- }
71
- },
72
-
73
- /**
74
- * Fails if the object does not have the required key(s).
75
- */
76
- contains: function(field, value, options) {
77
- var keys = Array.isArray(options) ? options : typeof options === 'string' ? [options] : [];
78
-
79
- for (var i = 0; i < keys.length; i++) {
80
- var requiredKey = keys[i];
81
-
82
- if (!value.hasOwnProperty(requiredKey)) {
83
- return createError(options.message || field + ' does not contain ' + requiredKey);
84
- }
85
- }
86
- }
87
- };
88
-
89
- /*********************************
90
- * Core validate function
91
- *
92
- * Iterates over each field in constraints, resolves its value from options,
93
- * then runs each rule's validator function in order.
94
- * Returns the first error encountered or undefined if all pass.
95
- *
96
- * @param {Object} options - The input object to validate
97
- * @param {Object} constraints - Map of field names to their rule constraints
98
- * @returns {DLSError | undefined}
99
- **********************************/
100
- function validate(options, constraints) {
101
- for (var field in constraints) {
102
- var fieldConstraintsObj = constraints[field];
103
- var value = getValue(options, field);
104
-
105
- for (var ruleName in fieldConstraintsObj) {
106
- var ruleOptions = fieldConstraintsObj[ruleName];
107
- var validatorFn = validators[ruleName];
108
-
109
- if (!validatorFn) { continue; }
110
-
111
- // Pass field name, field value, and field's rule constraint value to the validator function
112
- var error = validatorFn(field, value, ruleOptions);
113
- if (error) { return error; }
114
- }
115
- }
116
-
117
- return undefined;
118
- }
119
-
120
- /*********************************
121
- * Private helpers
122
- **********************************/
123
- function getValue(obj, path) {
124
- var keys = path.split('.');
125
- var result = obj;
126
-
127
- for (var i = 0; i < keys.length; i++) {
128
- if (result === undefined || result === null) { return undefined; }
129
- result = result[keys[i]];
130
- }
131
-
132
- return result;
133
- }
134
-
135
- function createError(message) {
136
- var msg = message || 'Validation error';
137
- msg = msg.charAt(0).toUpperCase() + msg.slice(1);
138
-
139
- return new DLSError(errors.ERROR_TYPES.SDK_ERROR, {
140
- message: msg,
141
- description: msg
142
- });
143
- }
144
-
145
- /*********************************
146
- * Exported auth validators
147
- **********************************/
148
-
149
- /**
150
- * This function validates if the SDK instance is authenticated.
151
- * It checks if the orgId and token are present.
152
- * @param {String} orgId - Organization ID
153
- * @param {Object} token - Token object { access_token: 'string' }
154
- */
155
- function validateIsAuthenticatedV2(orgId, token) {
156
- if (orgId && token) { return; }
157
-
158
- var errMsg = 'SDK Instance does not have valid orgid or token. ' +
159
- 'Please authenticate using authWithCredentials or authWithToken method.';
160
- var errObj = { message: errMsg, description: errMsg};
161
- return new DLSError(errors.ERROR_TYPES.SDK_ERROR, errObj);
162
- };
163
-
164
- /**
165
- * Validates if SDK instance is authenticated by checking presence of orgId and token.
166
- * @param {String} orgId - Organization ID
167
- * @param {Object} token - Token object { access_token: 'string' }
168
- */
169
- function validateIsAuthenticated(orgId, token) {
170
- var validate_options = {
171
- 'organization': orgId,
172
- 'token': token
173
- };
174
-
175
- var errMsg = 'SDK Instance does not have valid orgid or token. ' +
176
- 'Please authenticate using authWithCredentials or authWithToken method.';
177
-
178
- var validate_constraints = {
179
- 'organization': {
180
- 'presence': { 'message': errMsg }
181
- },
182
- 'token': {
183
- 'presence': { 'message': errMsg }
184
- }
185
- };
186
-
187
- return validate(validate_options, validate_constraints);
188
- };
189
-
190
- exports.validate = validate;
191
- exports.isAuthenticated = validateIsAuthenticated;
192
- exports.isAuthenticatedV2 = validateIsAuthenticatedV2;
1
+ /*************************************************************************
2
+ *
3
+ * COMPRO CONFIDENTIAL
4
+ * __________________
5
+ *
6
+ * [2015] - [2020] Compro Technologies Private Limited
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Compro Technologies Private Limited. The
11
+ * intellectual and technical concepts contained herein are
12
+ * proprietary to Compro Technologies Private Limited and may
13
+ * be covered by U.S. and Foreign Patents, patents in process,
14
+ * and are protected by trade secret or copyright law.
15
+ *
16
+ * Dissemination of this information or reproduction of this material
17
+ * is strictly forbidden unless prior written permission is obtained
18
+ * from Compro Technologies Pvt. Ltd..
19
+ ***************************************************************************/
20
+
21
+ /***********************************************************
22
+ * comproDLS SDK Validator Helper Module
23
+ * This module contains validation helper functions for comproDLS SDK
24
+ ************************************************************/
25
+
26
+ var errors = require('./errors');
27
+ var DLSError = errors.DLSError;
28
+
29
+ /*********************************
30
+ * Core validator utilities
31
+ * Each validator follows the signature:
32
+ * fn(field, value, options) → DLSError | undefined
33
+ *
34
+ * - field : the constraint key name e.g. 'organization', 'token', 'token.access_token'
35
+ * - value : the value from the options object for that field
36
+ * - options : the rule config, can be `true` or `{ message: '...' }`
37
+ * For `contains`, options is a string or array of required keys.
38
+ *
39
+ * Returning a DLSError which stops validation immediately.
40
+ * Returning undefined means the check passed.
41
+ **********************************/
42
+ var validators = {
43
+ /**
44
+ * Fails if value is null, undefined, or blank/whitespace-only string or empty object.
45
+ */
46
+ presence: function(field, value, options) {
47
+ if (value === undefined || value === null || value === '' ||
48
+ (typeof value == 'string' && value.trim() === '') ||
49
+ (typeof value == 'object' && Object.keys(value).length === 0)
50
+ ) {
51
+ return createError(options.message || field + ' can\'t be blank');
52
+ }
53
+ },
54
+
55
+ /**
56
+ * Fails if value is not a string.
57
+ */
58
+ isString: function(field, value, options) {
59
+ if (typeof value !== 'string') {
60
+ return createError(options.message || field + ' is not a valid string');
61
+ }
62
+ },
63
+
64
+ /**
65
+ * Fails if value is not an object.
66
+ */
67
+ isObject: function(field, value, options) {
68
+ if (typeof value !== 'object' || Array.isArray(value)) {
69
+ return createError(options.message || field + ' is not a valid object');
70
+ }
71
+ },
72
+
73
+ /**
74
+ * Fails if the object does not have the required key(s).
75
+ */
76
+ contains: function(field, value, options) {
77
+ var keys = Array.isArray(options) ? options : typeof options === 'string' ? [options] : [];
78
+
79
+ for (var i = 0; i < keys.length; i++) {
80
+ var requiredKey = keys[i];
81
+
82
+ if (!value.hasOwnProperty(requiredKey)) {
83
+ return createError(options.message || field + ' does not contain ' + requiredKey);
84
+ }
85
+ }
86
+ }
87
+ };
88
+
89
+ /*********************************
90
+ * Core validate function
91
+ *
92
+ * Iterates over each field in constraints, resolves its value from options,
93
+ * then runs each rule's validator function in order.
94
+ * Returns the first error encountered or undefined if all pass.
95
+ *
96
+ * @param {Object} options - The input object to validate
97
+ * @param {Object} constraints - Map of field names to their rule constraints
98
+ * @returns {DLSError | undefined}
99
+ **********************************/
100
+ function validate(options, constraints) {
101
+ for (var field in constraints) {
102
+ var fieldConstraintsObj = constraints[field];
103
+ var value = getValue(options, field);
104
+
105
+ for (var ruleName in fieldConstraintsObj) {
106
+ var ruleOptions = fieldConstraintsObj[ruleName];
107
+ var validatorFn = validators[ruleName];
108
+
109
+ if (!validatorFn) { continue; }
110
+
111
+ // Pass field name, field value, and field's rule constraint value to the validator function
112
+ var error = validatorFn(field, value, ruleOptions);
113
+ if (error) { return error; }
114
+ }
115
+ }
116
+
117
+ return undefined;
118
+ }
119
+
120
+ /*********************************
121
+ * Private helpers
122
+ **********************************/
123
+ function getValue(obj, path) {
124
+ var keys = path.split('.');
125
+ var result = obj;
126
+
127
+ for (var i = 0; i < keys.length; i++) {
128
+ if (result === undefined || result === null) { return undefined; }
129
+ result = result[keys[i]];
130
+ }
131
+
132
+ return result;
133
+ }
134
+
135
+ function createError(message) {
136
+ var msg = message || 'Validation error';
137
+ msg = msg.charAt(0).toUpperCase() + msg.slice(1);
138
+
139
+ return new DLSError(errors.ERROR_TYPES.SDK_ERROR, {
140
+ message: msg,
141
+ description: msg
142
+ });
143
+ }
144
+
145
+ /*********************************
146
+ * Exported auth validators
147
+ **********************************/
148
+
149
+ /**
150
+ * This function validates if the SDK instance is authenticated.
151
+ * It checks if the orgId and token are present.
152
+ * @param {String} orgId - Organization ID
153
+ * @param {Object} token - Token object { access_token: 'string' }
154
+ */
155
+ function validateIsAuthenticatedV2(orgId, token) {
156
+ if (orgId && token) { return; }
157
+
158
+ var errMsg = 'SDK Instance does not have valid orgid or token. ' +
159
+ 'Please authenticate using authWithCredentials or authWithToken method.';
160
+ var errObj = { message: errMsg, description: errMsg};
161
+ return new DLSError(errors.ERROR_TYPES.SDK_ERROR, errObj);
162
+ };
163
+
164
+ /**
165
+ * Validates if SDK instance is authenticated by checking presence of orgId and token.
166
+ * @param {String} orgId - Organization ID
167
+ * @param {Object} token - Token object { access_token: 'string' }
168
+ */
169
+ function validateIsAuthenticated(orgId, token) {
170
+ var validate_options = {
171
+ 'organization': orgId,
172
+ 'token': token
173
+ };
174
+
175
+ var errMsg = 'SDK Instance does not have valid orgid or token. ' +
176
+ 'Please authenticate using authWithCredentials or authWithToken method.';
177
+
178
+ var validate_constraints = {
179
+ 'organization': {
180
+ 'presence': { 'message': errMsg }
181
+ },
182
+ 'token': {
183
+ 'presence': { 'message': errMsg }
184
+ }
185
+ };
186
+
187
+ return validate(validate_options, validate_constraints);
188
+ };
189
+
190
+ exports.validate = validate;
191
+ exports.isAuthenticated = validateIsAuthenticated;
192
+ exports.isAuthenticatedV2 = validateIsAuthenticatedV2;
@@ -1,116 +1,116 @@
1
- /*************************************************************************
2
- *
3
- * COMPRO CONFIDENTIAL
4
- * __________________
5
- *
6
- * [2015] - [2020] Compro Technologies Private Limited
7
- * All Rights Reserved.
8
- *
9
- * NOTICE: All information contained herein is, and remains
10
- * the property of Compro Technologies Private Limited. The
11
- * intellectual and technical concepts contained herein are
12
- * proprietary to Compro Technologies Private Limited and may
13
- * be covered by U.S. and Foreign Patents, patents in process,
14
- * and are protected by trade secret or copyright law.
15
- *
16
- * Dissemination of this information or reproduction of this material
17
- * is strictly forbidden unless prior written permission is obtained
18
- * from Compro Technologies Pvt. Ltd..
19
- ***************************************************************************/
20
-
21
- /***********************************************************
22
- * comproDLS SDK Open Access Manager Module
23
- * Provides Open Access functions for the SDK
24
- ************************************************************/
25
- var q = require('q');
26
- var request = require('superagent');
27
- var helpers = require('../helpers');
28
- var DLSError = helpers.errors.DLSError;
29
-
30
- /**
31
- * These functions need to be moved to the corresponding adapter
32
- * They were created here since these functions requires the orgid but not token,
33
- * But the initialiation function required both token and orgid to be initialized,
34
- * Now we have improved the initialization function for orgid.
35
- */
36
- exports.getClassEnrolmentsStat = getClassEnrolmentsStat;
37
- exports.getSingleInvitation = getSingleInvitation;
38
-
39
- /*********************************
40
- * Public Function definitions
41
- **********************************/
42
-
43
- /**
44
- * Wiki Link for SDK params
45
- * https://github.com/comprodls/comprodls-sdk-js/wiki/17_Open-Access-SDK-Functions#getclassenrolmentsstatorganizationid-options
46
- */
47
- function getClassEnrolmentsStat(organizationId, options) {
48
- var self = this;
49
- //Initializing promise
50
- var dfd = q.defer(), err = {};
51
- //Validations
52
- if(organizationId && options && options.classid) {
53
- //Passed all validations, Contruct API url
54
- var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassEnrolmentsStat;
55
- url = helpers.api.constructAPIUrl(url, { orgId: organizationId });
56
-
57
- //Setup request with URL
58
- var requestAPI = request.get(url).query(options);
59
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
60
-
61
- requestAPI.end(function(err, response) {
62
- if(err) {
63
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
64
- dfd.reject(err);
65
- }
66
- else { dfd.resolve(response.body); }
67
- });
68
- }
69
- else {
70
- err.message = err.description = 'Mandatory params not found in request body : [orgid, classid]';
71
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
72
- dfd.reject(err);
73
- }
74
- return dfd.promise;
75
- }
76
-
77
- /**
78
- * Wiki Link for SDK params
79
- * https://github.com/comprodls/comprodls-sdk-js/wiki/17_Open-Access-SDK-Functions#getsingleinvitationorganizationid-params
80
- */
81
- function getSingleInvitation(organizationId, options) {
82
- var self = this;
83
- var err = {};
84
- // Initializing promise
85
- var dfd = q.defer();
86
- if (organizationId && options && options.context_id && options.context &&
87
- options.invitationid) {
88
- // Passed all validations, Contruct API url
89
- var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getSingleInvitation;
90
- //Contruct path parameters
91
- url = helpers.api.constructAPIUrl(url,
92
- { orgId: organizationId, invitationId: options.invitationid });
93
- var queryParam = { context: options.context, context_id: options.context_id };
94
-
95
- // Setup request with URL and Params
96
- var requestAPI = request.get(url).query(queryParam);
97
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
98
-
99
- requestAPI.end(function (error, response) {
100
- if (error) {
101
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
102
- dfd.reject(err);
103
- }
104
- else {
105
- dfd.resolve(response.body);
106
- }
107
- });
108
- }
109
- else {
110
- err.message = err.description = 'organizationId or context_id or context '+
111
- 'or invitationid not found in request options.';
112
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
113
- dfd.reject(err);
114
- }
115
- return dfd.promise;
116
- }
1
+ /*************************************************************************
2
+ *
3
+ * COMPRO CONFIDENTIAL
4
+ * __________________
5
+ *
6
+ * [2015] - [2020] Compro Technologies Private Limited
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Compro Technologies Private Limited. The
11
+ * intellectual and technical concepts contained herein are
12
+ * proprietary to Compro Technologies Private Limited and may
13
+ * be covered by U.S. and Foreign Patents, patents in process,
14
+ * and are protected by trade secret or copyright law.
15
+ *
16
+ * Dissemination of this information or reproduction of this material
17
+ * is strictly forbidden unless prior written permission is obtained
18
+ * from Compro Technologies Pvt. Ltd..
19
+ ***************************************************************************/
20
+
21
+ /***********************************************************
22
+ * comproDLS SDK Open Access Manager Module
23
+ * Provides Open Access functions for the SDK
24
+ ************************************************************/
25
+ var q = require('q');
26
+ var request = require('superagent');
27
+ var helpers = require('../helpers');
28
+ var DLSError = helpers.errors.DLSError;
29
+
30
+ /**
31
+ * These functions need to be moved to the corresponding adapter
32
+ * They were created here since these functions requires the orgid but not token,
33
+ * But the initialiation function required both token and orgid to be initialized,
34
+ * Now we have improved the initialization function for orgid.
35
+ */
36
+ exports.getClassEnrolmentsStat = getClassEnrolmentsStat;
37
+ exports.getSingleInvitation = getSingleInvitation;
38
+
39
+ /*********************************
40
+ * Public Function definitions
41
+ **********************************/
42
+
43
+ /**
44
+ * Wiki Link for SDK params
45
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/17_Open-Access-SDK-Functions#getclassenrolmentsstatorganizationid-options
46
+ */
47
+ function getClassEnrolmentsStat(organizationId, options) {
48
+ var self = this;
49
+ //Initializing promise
50
+ var dfd = q.defer(), err = {};
51
+ //Validations
52
+ if(organizationId && options && options.classid) {
53
+ //Passed all validations, Contruct API url
54
+ var url = self.config.DEFAULT_HOSTS['ANALYTICS'] + self.config.ANALYTICS_API_URLS.getClassEnrolmentsStat;
55
+ url = helpers.api.constructAPIUrl(url, { orgId: organizationId });
56
+
57
+ //Setup request with URL
58
+ var requestAPI = request.get(url).query(options);
59
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
60
+
61
+ requestAPI.end(function(err, response) {
62
+ if(err) {
63
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
64
+ dfd.reject(err);
65
+ }
66
+ else { dfd.resolve(response.body); }
67
+ });
68
+ }
69
+ else {
70
+ err.message = err.description = 'Mandatory params not found in request body : [orgid, classid]';
71
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
72
+ dfd.reject(err);
73
+ }
74
+ return dfd.promise;
75
+ }
76
+
77
+ /**
78
+ * Wiki Link for SDK params
79
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/17_Open-Access-SDK-Functions#getsingleinvitationorganizationid-params
80
+ */
81
+ function getSingleInvitation(organizationId, options) {
82
+ var self = this;
83
+ var err = {};
84
+ // Initializing promise
85
+ var dfd = q.defer();
86
+ if (organizationId && options && options.context_id && options.context &&
87
+ options.invitationid) {
88
+ // Passed all validations, Contruct API url
89
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getSingleInvitation;
90
+ //Contruct path parameters
91
+ url = helpers.api.constructAPIUrl(url,
92
+ { orgId: organizationId, invitationId: options.invitationid });
93
+ var queryParam = { context: options.context, context_id: options.context_id };
94
+
95
+ // Setup request with URL and Params
96
+ var requestAPI = request.get(url).query(queryParam);
97
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
98
+
99
+ requestAPI.end(function (error, response) {
100
+ if (error) {
101
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
102
+ dfd.reject(err);
103
+ }
104
+ else {
105
+ dfd.resolve(response.body);
106
+ }
107
+ });
108
+ }
109
+ else {
110
+ err.message = err.description = 'organizationId or context_id or context '+
111
+ 'or invitationid not found in request options.';
112
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
113
+ dfd.reject(err);
114
+ }
115
+ return dfd.promise;
116
+ }