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.
- package/.eslintrc +28 -28
- package/.github/workflows/npm-publish.yml +76 -0
- package/README.md +235 -235
- package/dist/comprodls-sdk.js +13543 -13543
- package/docs/npm-oidc-publishing-runbook.md +229 -0
- package/lib/comprodls.js +132 -132
- package/lib/config/index.js +356 -356
- package/lib/helpers/index.js +31 -31
- package/lib/helpers/lib/api/converter.js +129 -129
- package/lib/helpers/lib/api/index.js +46 -46
- package/lib/helpers/lib/errors.js +122 -122
- package/lib/helpers/lib/requestLayer.js +154 -154
- package/lib/helpers/lib/validator.js +192 -192
- package/lib/open_access/index.js +116 -116
- package/lib/services/analytics/index.js +1365 -1365
- package/lib/services/attempts/index.js +389 -389
- package/lib/services/auth/index.js +3708 -3708
- package/lib/services/authextn/index.js +1032 -1032
- package/lib/services/datasyncmanager/index.js +275 -275
- package/lib/services/drive/index.js +270 -270
- package/lib/services/integrations/index.js +525 -525
- package/lib/services/invitations/index.js +282 -282
- package/lib/services/product/index.js +343 -343
- package/lib/services/pub/index.js +530 -530
- package/lib/services/pushX/index.js +251 -251
- package/lib/services/pushX/pubnubClientWrapper.js +438 -438
- package/lib/services/rules/index.js +416 -416
- package/lib/services/spaces/index.js +999 -999
- package/lib/services/spacesextn/index.js +131 -131
- package/lib/services/superuser/index.js +160 -160
- package/lib/services/taxonomy/index.js +405 -405
- package/lib/services/workflows/index.js +406 -406
- package/lib/services/xapi/index.js +114 -114
- package/lib/token/index.js +120 -120
- package/lib/token/validations.js +85 -85
- package/package.json +5 -1
|
@@ -1,282 +1,282 @@
|
|
|
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 AUTH API Adaptor
|
|
23
|
-
* Functions for calling AUTH API.
|
|
24
|
-
************************************************************/
|
|
25
|
-
|
|
26
|
-
var q = require('q');
|
|
27
|
-
var request = require('superagent');
|
|
28
|
-
var helpers = require('../../helpers');
|
|
29
|
-
var DLSError = helpers.errors.DLSError;
|
|
30
|
-
|
|
31
|
-
module.exports = invitations;
|
|
32
|
-
|
|
33
|
-
//Invitations Adaptor Constructor
|
|
34
|
-
function invitations() {
|
|
35
|
-
return {
|
|
36
|
-
sendInvitations: sendInvitations.bind(this),
|
|
37
|
-
getMultiInvitations: getMultiInvitations.bind(this),
|
|
38
|
-
revokeSingleInvitation: revokeSingleInvitation.bind(this),
|
|
39
|
-
completeSingleInvitation: completeSingleInvitation.bind(this),
|
|
40
|
-
resendSingleInvitation: resendSingleInvitation.bind(this)
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Wiki Link for SDK params
|
|
46
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#sendInvitationsparams
|
|
47
|
-
*/
|
|
48
|
-
function sendInvitations(options) {
|
|
49
|
-
var self = this;
|
|
50
|
-
var dfd = q.defer();
|
|
51
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
52
|
-
if(err) { dfd.reject(err); }
|
|
53
|
-
else {
|
|
54
|
-
if (options && options.context && options.created && options['invitation_data']) {
|
|
55
|
-
// Passed all validations, Contruct API url
|
|
56
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.sendInvitations;
|
|
57
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
58
|
-
// Setup request with URL and Params
|
|
59
|
-
var requestAPI = request.post(url)
|
|
60
|
-
.set('Content-Type', 'application/json')
|
|
61
|
-
.set('Accept', 'application/json')
|
|
62
|
-
.send(options);
|
|
63
|
-
|
|
64
|
-
//Setup token in Authorization header
|
|
65
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
66
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
67
|
-
|
|
68
|
-
requestAPI.end(function (error, response) {
|
|
69
|
-
if (error) {
|
|
70
|
-
err = {};
|
|
71
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
72
|
-
dfd.reject(err);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
dfd.resolve(response.body);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
err = {};
|
|
81
|
-
err.message = err.description = 'One or more required field(s) missing: context, created or '+
|
|
82
|
-
'invitation_data';
|
|
83
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
84
|
-
dfd.reject(err);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return dfd.promise;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Wiki Link for SDK params
|
|
92
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#getmultiinvitationsparams
|
|
93
|
-
*/
|
|
94
|
-
function getMultiInvitations(options) {
|
|
95
|
-
var self = this;
|
|
96
|
-
// Initializing promise
|
|
97
|
-
var dfd = q.defer();
|
|
98
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
99
|
-
if(err) { dfd.reject(err); }
|
|
100
|
-
else {
|
|
101
|
-
if (options && options.context_id) {
|
|
102
|
-
|
|
103
|
-
// Passed all validations, Contruct API url
|
|
104
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getMultiInvitations;
|
|
105
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
106
|
-
|
|
107
|
-
var queryParam = { context_id: options.context_id };
|
|
108
|
-
if (options.context) { queryParam.context = options.context; }
|
|
109
|
-
if (options.status) { queryParam.status = options.status; }
|
|
110
|
-
if (options.cursor) { queryParam.cursor = options.cursor; }
|
|
111
|
-
|
|
112
|
-
// Setup request with URL and Params
|
|
113
|
-
var requestAPI = request.get(url).query(queryParam);
|
|
114
|
-
|
|
115
|
-
//Setup token in Authorization header
|
|
116
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
117
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
118
|
-
|
|
119
|
-
requestAPI.end(function (error, response) {
|
|
120
|
-
if (error) {
|
|
121
|
-
err = {};
|
|
122
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
123
|
-
dfd.reject(err);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
dfd.resolve(response.body);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
err = {};
|
|
132
|
-
err.message = err.description = 'context_id not found in request options.';
|
|
133
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
134
|
-
dfd.reject(err);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return dfd.promise;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Wiki Link for SDK params
|
|
142
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#revokesingleinvitationparams
|
|
143
|
-
*/
|
|
144
|
-
function revokeSingleInvitation(options) {
|
|
145
|
-
var self = this;
|
|
146
|
-
// Initializing promise
|
|
147
|
-
var dfd = q.defer();
|
|
148
|
-
|
|
149
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
150
|
-
if(err) { dfd.reject(err); }
|
|
151
|
-
else {
|
|
152
|
-
if (options && options.context_id && options.invitationid && options.context) {
|
|
153
|
-
// Passed all validations, Contruct API url
|
|
154
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.revokeSingleInvitation;
|
|
155
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
156
|
-
|
|
157
|
-
var queryParam = { context: options.context, context_id: options.context_id };
|
|
158
|
-
|
|
159
|
-
// Setup request with URL and Params
|
|
160
|
-
var requestAPI = request.delete(url).query(queryParam);
|
|
161
|
-
|
|
162
|
-
//Setup token in Authorization header
|
|
163
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
164
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
165
|
-
|
|
166
|
-
requestAPI.end(function (error, response) {
|
|
167
|
-
if (error) {
|
|
168
|
-
err = {};
|
|
169
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
170
|
-
dfd.reject(err);
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
dfd.resolve(response.body);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
err = {};
|
|
179
|
-
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
180
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
181
|
-
dfd.reject(err);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return dfd.promise;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Wiki Link for SDK params
|
|
189
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#completesingleinvitationparams
|
|
190
|
-
*/
|
|
191
|
-
function completeSingleInvitation(options) {
|
|
192
|
-
var self = this;
|
|
193
|
-
// Initializing promise
|
|
194
|
-
var dfd = q.defer();
|
|
195
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
196
|
-
if(err) { dfd.reject(err); }
|
|
197
|
-
else {
|
|
198
|
-
if (options && options.context_id && options.invitationid && options.context) {
|
|
199
|
-
// Passed all validations, Contruct API url
|
|
200
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.completeSingleInvitation;
|
|
201
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
202
|
-
|
|
203
|
-
var queryParam = { context: options.context, context_id: options.context_id };
|
|
204
|
-
// Setup request with URL and Params
|
|
205
|
-
var requestAPI = request.put(url).query(queryParam)
|
|
206
|
-
.set('Content-Type', 'application/json')
|
|
207
|
-
.set('Accept', 'application/json')
|
|
208
|
-
.send({});
|
|
209
|
-
|
|
210
|
-
//Setup token in Authorization header
|
|
211
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
212
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
213
|
-
|
|
214
|
-
requestAPI.end(function (error, response) {
|
|
215
|
-
if (error) {
|
|
216
|
-
err = {};
|
|
217
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
218
|
-
dfd.reject(err);
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
dfd.resolve(response.body);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
err = {};
|
|
227
|
-
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
228
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
229
|
-
dfd.reject(err);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return dfd.promise;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Wiki Link for SDK params
|
|
237
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#resendsingleinvitationparams
|
|
238
|
-
*/
|
|
239
|
-
function resendSingleInvitation(options) {
|
|
240
|
-
var self = this;
|
|
241
|
-
// Initializing promise
|
|
242
|
-
var dfd = q.defer();
|
|
243
|
-
|
|
244
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
245
|
-
if(err) { dfd.reject(err); }
|
|
246
|
-
else {
|
|
247
|
-
if (options && options.invitationid && options.context && options.context_id) {
|
|
248
|
-
// Passed all validations, Contruct API url
|
|
249
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.resendSingleInvitation;
|
|
250
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
251
|
-
var queryParam = { context: options.context, context_id: options.context_id };
|
|
252
|
-
var body = {};
|
|
253
|
-
if(options.space_title) { body.space_title = options.space_title; }
|
|
254
|
-
|
|
255
|
-
// Setup request with URL and Params
|
|
256
|
-
var requestAPI = request.put(url).query(queryParam)
|
|
257
|
-
.set('Content-Type', 'application/json')
|
|
258
|
-
.set('Accept', 'application/json')
|
|
259
|
-
.send(body);
|
|
260
|
-
|
|
261
|
-
//Setup token in Authorization header
|
|
262
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
263
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
264
|
-
|
|
265
|
-
requestAPI.end(function (error, response) {
|
|
266
|
-
if (error) {
|
|
267
|
-
err = {};
|
|
268
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
269
|
-
dfd.reject(err);
|
|
270
|
-
}
|
|
271
|
-
else { dfd.resolve(response.body); }
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
err = {};
|
|
276
|
-
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
277
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
278
|
-
dfd.reject(err);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return dfd.promise;
|
|
282
|
-
}
|
|
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 AUTH API Adaptor
|
|
23
|
+
* Functions for calling AUTH API.
|
|
24
|
+
************************************************************/
|
|
25
|
+
|
|
26
|
+
var q = require('q');
|
|
27
|
+
var request = require('superagent');
|
|
28
|
+
var helpers = require('../../helpers');
|
|
29
|
+
var DLSError = helpers.errors.DLSError;
|
|
30
|
+
|
|
31
|
+
module.exports = invitations;
|
|
32
|
+
|
|
33
|
+
//Invitations Adaptor Constructor
|
|
34
|
+
function invitations() {
|
|
35
|
+
return {
|
|
36
|
+
sendInvitations: sendInvitations.bind(this),
|
|
37
|
+
getMultiInvitations: getMultiInvitations.bind(this),
|
|
38
|
+
revokeSingleInvitation: revokeSingleInvitation.bind(this),
|
|
39
|
+
completeSingleInvitation: completeSingleInvitation.bind(this),
|
|
40
|
+
resendSingleInvitation: resendSingleInvitation.bind(this)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Wiki Link for SDK params
|
|
46
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#sendInvitationsparams
|
|
47
|
+
*/
|
|
48
|
+
function sendInvitations(options) {
|
|
49
|
+
var self = this;
|
|
50
|
+
var dfd = q.defer();
|
|
51
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
52
|
+
if(err) { dfd.reject(err); }
|
|
53
|
+
else {
|
|
54
|
+
if (options && options.context && options.created && options['invitation_data']) {
|
|
55
|
+
// Passed all validations, Contruct API url
|
|
56
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.sendInvitations;
|
|
57
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
58
|
+
// Setup request with URL and Params
|
|
59
|
+
var requestAPI = request.post(url)
|
|
60
|
+
.set('Content-Type', 'application/json')
|
|
61
|
+
.set('Accept', 'application/json')
|
|
62
|
+
.send(options);
|
|
63
|
+
|
|
64
|
+
//Setup token in Authorization header
|
|
65
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
66
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
67
|
+
|
|
68
|
+
requestAPI.end(function (error, response) {
|
|
69
|
+
if (error) {
|
|
70
|
+
err = {};
|
|
71
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
72
|
+
dfd.reject(err);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
dfd.resolve(response.body);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
err = {};
|
|
81
|
+
err.message = err.description = 'One or more required field(s) missing: context, created or '+
|
|
82
|
+
'invitation_data';
|
|
83
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
84
|
+
dfd.reject(err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return dfd.promise;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Wiki Link for SDK params
|
|
92
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#getmultiinvitationsparams
|
|
93
|
+
*/
|
|
94
|
+
function getMultiInvitations(options) {
|
|
95
|
+
var self = this;
|
|
96
|
+
// Initializing promise
|
|
97
|
+
var dfd = q.defer();
|
|
98
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
99
|
+
if(err) { dfd.reject(err); }
|
|
100
|
+
else {
|
|
101
|
+
if (options && options.context_id) {
|
|
102
|
+
|
|
103
|
+
// Passed all validations, Contruct API url
|
|
104
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getMultiInvitations;
|
|
105
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
106
|
+
|
|
107
|
+
var queryParam = { context_id: options.context_id };
|
|
108
|
+
if (options.context) { queryParam.context = options.context; }
|
|
109
|
+
if (options.status) { queryParam.status = options.status; }
|
|
110
|
+
if (options.cursor) { queryParam.cursor = options.cursor; }
|
|
111
|
+
|
|
112
|
+
// Setup request with URL and Params
|
|
113
|
+
var requestAPI = request.get(url).query(queryParam);
|
|
114
|
+
|
|
115
|
+
//Setup token in Authorization header
|
|
116
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
117
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
118
|
+
|
|
119
|
+
requestAPI.end(function (error, response) {
|
|
120
|
+
if (error) {
|
|
121
|
+
err = {};
|
|
122
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
123
|
+
dfd.reject(err);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
dfd.resolve(response.body);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
err = {};
|
|
132
|
+
err.message = err.description = 'context_id not found in request options.';
|
|
133
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
134
|
+
dfd.reject(err);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return dfd.promise;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Wiki Link for SDK params
|
|
142
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#revokesingleinvitationparams
|
|
143
|
+
*/
|
|
144
|
+
function revokeSingleInvitation(options) {
|
|
145
|
+
var self = this;
|
|
146
|
+
// Initializing promise
|
|
147
|
+
var dfd = q.defer();
|
|
148
|
+
|
|
149
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
150
|
+
if(err) { dfd.reject(err); }
|
|
151
|
+
else {
|
|
152
|
+
if (options && options.context_id && options.invitationid && options.context) {
|
|
153
|
+
// Passed all validations, Contruct API url
|
|
154
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.revokeSingleInvitation;
|
|
155
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
156
|
+
|
|
157
|
+
var queryParam = { context: options.context, context_id: options.context_id };
|
|
158
|
+
|
|
159
|
+
// Setup request with URL and Params
|
|
160
|
+
var requestAPI = request.delete(url).query(queryParam);
|
|
161
|
+
|
|
162
|
+
//Setup token in Authorization header
|
|
163
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
164
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
165
|
+
|
|
166
|
+
requestAPI.end(function (error, response) {
|
|
167
|
+
if (error) {
|
|
168
|
+
err = {};
|
|
169
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
170
|
+
dfd.reject(err);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
dfd.resolve(response.body);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
err = {};
|
|
179
|
+
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
180
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
181
|
+
dfd.reject(err);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return dfd.promise;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Wiki Link for SDK params
|
|
189
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#completesingleinvitationparams
|
|
190
|
+
*/
|
|
191
|
+
function completeSingleInvitation(options) {
|
|
192
|
+
var self = this;
|
|
193
|
+
// Initializing promise
|
|
194
|
+
var dfd = q.defer();
|
|
195
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
196
|
+
if(err) { dfd.reject(err); }
|
|
197
|
+
else {
|
|
198
|
+
if (options && options.context_id && options.invitationid && options.context) {
|
|
199
|
+
// Passed all validations, Contruct API url
|
|
200
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.completeSingleInvitation;
|
|
201
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
202
|
+
|
|
203
|
+
var queryParam = { context: options.context, context_id: options.context_id };
|
|
204
|
+
// Setup request with URL and Params
|
|
205
|
+
var requestAPI = request.put(url).query(queryParam)
|
|
206
|
+
.set('Content-Type', 'application/json')
|
|
207
|
+
.set('Accept', 'application/json')
|
|
208
|
+
.send({});
|
|
209
|
+
|
|
210
|
+
//Setup token in Authorization header
|
|
211
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
212
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
213
|
+
|
|
214
|
+
requestAPI.end(function (error, response) {
|
|
215
|
+
if (error) {
|
|
216
|
+
err = {};
|
|
217
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
218
|
+
dfd.reject(err);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
dfd.resolve(response.body);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
err = {};
|
|
227
|
+
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
228
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
229
|
+
dfd.reject(err);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return dfd.promise;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Wiki Link for SDK params
|
|
237
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/20_Invitations-Adapter#resendsingleinvitationparams
|
|
238
|
+
*/
|
|
239
|
+
function resendSingleInvitation(options) {
|
|
240
|
+
var self = this;
|
|
241
|
+
// Initializing promise
|
|
242
|
+
var dfd = q.defer();
|
|
243
|
+
|
|
244
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
245
|
+
if(err) { dfd.reject(err); }
|
|
246
|
+
else {
|
|
247
|
+
if (options && options.invitationid && options.context && options.context_id) {
|
|
248
|
+
// Passed all validations, Contruct API url
|
|
249
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.resendSingleInvitation;
|
|
250
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
251
|
+
var queryParam = { context: options.context, context_id: options.context_id };
|
|
252
|
+
var body = {};
|
|
253
|
+
if(options.space_title) { body.space_title = options.space_title; }
|
|
254
|
+
|
|
255
|
+
// Setup request with URL and Params
|
|
256
|
+
var requestAPI = request.put(url).query(queryParam)
|
|
257
|
+
.set('Content-Type', 'application/json')
|
|
258
|
+
.set('Accept', 'application/json')
|
|
259
|
+
.send(body);
|
|
260
|
+
|
|
261
|
+
//Setup token in Authorization header
|
|
262
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
263
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
264
|
+
|
|
265
|
+
requestAPI.end(function (error, response) {
|
|
266
|
+
if (error) {
|
|
267
|
+
err = {};
|
|
268
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
269
|
+
dfd.reject(err);
|
|
270
|
+
}
|
|
271
|
+
else { dfd.resolve(response.body); }
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
err = {};
|
|
276
|
+
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
277
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
278
|
+
dfd.reject(err);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return dfd.promise;
|
|
282
|
+
}
|