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,114 +1,114 @@
|
|
|
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 xAPI Adaptor
|
|
23
|
-
* Functions for calling xAPI.
|
|
24
|
-
************************************************************/
|
|
25
|
-
|
|
26
|
-
var q = require('q');
|
|
27
|
-
var request = require('superagent');
|
|
28
|
-
|
|
29
|
-
var helpers = require('../../helpers');
|
|
30
|
-
var DLSError = helpers.errors.DLSError;
|
|
31
|
-
|
|
32
|
-
module.exports = xapi;
|
|
33
|
-
|
|
34
|
-
/*********************************
|
|
35
|
-
* Public Function definitions
|
|
36
|
-
**********************************/
|
|
37
|
-
function xapi(accountId) {
|
|
38
|
-
this.accountId = accountId;
|
|
39
|
-
return {
|
|
40
|
-
postStatement: postStatements.bind(this),
|
|
41
|
-
postExternalStatements: postExternalStatements.bind(this)
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Wiki Link for SDK params
|
|
47
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/08_XAPI-Adapter#poststatementsparams
|
|
48
|
-
*/
|
|
49
|
-
function postStatements(options) {
|
|
50
|
-
var self = this;
|
|
51
|
-
|
|
52
|
-
//Initializing promise
|
|
53
|
-
var dfd = q.defer();
|
|
54
|
-
//Validations
|
|
55
|
-
var err = {}, url;
|
|
56
|
-
|
|
57
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
58
|
-
if(err) { dfd.reject(err); }
|
|
59
|
-
else {
|
|
60
|
-
url = self.config.DEFAULT_HOSTS.XAPI +
|
|
61
|
-
self.config.XAPI_API_URLS.postMultiStatements;
|
|
62
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
63
|
-
//Passed all validations, Construct API url
|
|
64
|
-
|
|
65
|
-
var params = options;
|
|
66
|
-
|
|
67
|
-
//Setup request with URL and Params
|
|
68
|
-
var requestAPI = request.post(url).send(params);
|
|
69
|
-
|
|
70
|
-
//Setup token in Authorization header
|
|
71
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
72
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
73
|
-
|
|
74
|
-
//Call Product Timespent Api
|
|
75
|
-
|
|
76
|
-
requestAPI.end(function(err, response) {
|
|
77
|
-
if(err) {
|
|
78
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
79
|
-
dfd.reject(err);
|
|
80
|
-
}
|
|
81
|
-
else { dfd.resolve(response.body); }
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return dfd.promise;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Wiki Link for SDK params
|
|
89
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/08_XAPI-Adapter#postexternalstatementsparams
|
|
90
|
-
*/
|
|
91
|
-
function postExternalStatements(options) {
|
|
92
|
-
var self = this;
|
|
93
|
-
var dfd = q.defer();
|
|
94
|
-
|
|
95
|
-
var url = self.config.DEFAULT_HOSTS.XAPI + self.config.XAPI_API_URLS.postExternalMultiStatements;
|
|
96
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
97
|
-
//Passed all validations, Construct API url
|
|
98
|
-
|
|
99
|
-
//Setup request with URL and Params
|
|
100
|
-
var requestAPI = request.post(url).send(options);
|
|
101
|
-
|
|
102
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
103
|
-
|
|
104
|
-
//Call Product Timespent Api
|
|
105
|
-
|
|
106
|
-
requestAPI.end(function(err, response) {
|
|
107
|
-
if(err) {
|
|
108
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
109
|
-
dfd.reject(err);
|
|
110
|
-
}
|
|
111
|
-
else { dfd.resolve(response.body); }
|
|
112
|
-
});
|
|
113
|
-
return dfd.promise;
|
|
114
|
-
}
|
|
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 xAPI Adaptor
|
|
23
|
+
* Functions for calling xAPI.
|
|
24
|
+
************************************************************/
|
|
25
|
+
|
|
26
|
+
var q = require('q');
|
|
27
|
+
var request = require('superagent');
|
|
28
|
+
|
|
29
|
+
var helpers = require('../../helpers');
|
|
30
|
+
var DLSError = helpers.errors.DLSError;
|
|
31
|
+
|
|
32
|
+
module.exports = xapi;
|
|
33
|
+
|
|
34
|
+
/*********************************
|
|
35
|
+
* Public Function definitions
|
|
36
|
+
**********************************/
|
|
37
|
+
function xapi(accountId) {
|
|
38
|
+
this.accountId = accountId;
|
|
39
|
+
return {
|
|
40
|
+
postStatement: postStatements.bind(this),
|
|
41
|
+
postExternalStatements: postExternalStatements.bind(this)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Wiki Link for SDK params
|
|
47
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/08_XAPI-Adapter#poststatementsparams
|
|
48
|
+
*/
|
|
49
|
+
function postStatements(options) {
|
|
50
|
+
var self = this;
|
|
51
|
+
|
|
52
|
+
//Initializing promise
|
|
53
|
+
var dfd = q.defer();
|
|
54
|
+
//Validations
|
|
55
|
+
var err = {}, url;
|
|
56
|
+
|
|
57
|
+
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
58
|
+
if(err) { dfd.reject(err); }
|
|
59
|
+
else {
|
|
60
|
+
url = self.config.DEFAULT_HOSTS.XAPI +
|
|
61
|
+
self.config.XAPI_API_URLS.postMultiStatements;
|
|
62
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
63
|
+
//Passed all validations, Construct API url
|
|
64
|
+
|
|
65
|
+
var params = options;
|
|
66
|
+
|
|
67
|
+
//Setup request with URL and Params
|
|
68
|
+
var requestAPI = request.post(url).send(params);
|
|
69
|
+
|
|
70
|
+
//Setup token in Authorization header
|
|
71
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
72
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
73
|
+
|
|
74
|
+
//Call Product Timespent Api
|
|
75
|
+
|
|
76
|
+
requestAPI.end(function(err, response) {
|
|
77
|
+
if(err) {
|
|
78
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
79
|
+
dfd.reject(err);
|
|
80
|
+
}
|
|
81
|
+
else { dfd.resolve(response.body); }
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return dfd.promise;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Wiki Link for SDK params
|
|
89
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/08_XAPI-Adapter#postexternalstatementsparams
|
|
90
|
+
*/
|
|
91
|
+
function postExternalStatements(options) {
|
|
92
|
+
var self = this;
|
|
93
|
+
var dfd = q.defer();
|
|
94
|
+
|
|
95
|
+
var url = self.config.DEFAULT_HOSTS.XAPI + self.config.XAPI_API_URLS.postExternalMultiStatements;
|
|
96
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
97
|
+
//Passed all validations, Construct API url
|
|
98
|
+
|
|
99
|
+
//Setup request with URL and Params
|
|
100
|
+
var requestAPI = request.post(url).send(options);
|
|
101
|
+
|
|
102
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
103
|
+
|
|
104
|
+
//Call Product Timespent Api
|
|
105
|
+
|
|
106
|
+
requestAPI.end(function(err, response) {
|
|
107
|
+
if(err) {
|
|
108
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
109
|
+
dfd.reject(err);
|
|
110
|
+
}
|
|
111
|
+
else { dfd.resolve(response.body); }
|
|
112
|
+
});
|
|
113
|
+
return dfd.promise;
|
|
114
|
+
}
|
package/lib/token/index.js
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
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 Token Manager Module
|
|
23
|
-
* Provides Token managements functions for the SDK
|
|
24
|
-
************************************************************/
|
|
25
|
-
var request = require('superagent');
|
|
26
|
-
var q = require('q');
|
|
27
|
-
|
|
28
|
-
var helpers = require('../helpers');
|
|
29
|
-
var DLSError = helpers.errors.DLSError;
|
|
30
|
-
var validations = require('./validations');
|
|
31
|
-
|
|
32
|
-
exports.authWithExtUser = authWithExtUser;
|
|
33
|
-
exports.authWithToken = authWithToken;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Wiki Link for SDK params
|
|
38
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/02_Authentication-and-Tokens#authwithextuser
|
|
39
|
-
*/
|
|
40
|
-
function authWithExtUser(organizationId, options) {
|
|
41
|
-
var self = this;
|
|
42
|
-
var dfd = q.defer();
|
|
43
|
-
|
|
44
|
-
//Validation
|
|
45
|
-
var err = validations.validateAuthWithExtUser(organizationId, options);
|
|
46
|
-
if (err) {
|
|
47
|
-
dfd.reject(err);
|
|
48
|
-
} else {
|
|
49
|
-
//Passed all Validations, Setup the GET TOKEN API URL.
|
|
50
|
-
var url = this.config.DEFAULT_HOSTS['AUTH'] + this.config.AUTH_API_URLS.getExtUserTokenAPI;
|
|
51
|
-
url = helpers.api.constructAPIUrl(url, {'orgId' : organizationId});
|
|
52
|
-
|
|
53
|
-
//Setup Credentials
|
|
54
|
-
var params = {
|
|
55
|
-
'ext_user_id': options.ext_user_id
|
|
56
|
-
};
|
|
57
|
-
//Call the comproDLS GET TOKEN API
|
|
58
|
-
request.post(url).send(params).end(function(err, response) {
|
|
59
|
-
if (err) {
|
|
60
|
-
//API Error, Construct Standard SDK error response
|
|
61
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
62
|
-
dfd.reject(err);
|
|
63
|
-
} else {
|
|
64
|
-
//Success, Extract the Token & Other useful information
|
|
65
|
-
var token = {
|
|
66
|
-
'access_token': response.body.access_token
|
|
67
|
-
};
|
|
68
|
-
var user = response.body.user;
|
|
69
|
-
var responseObj = {
|
|
70
|
-
'token': token,
|
|
71
|
-
'user': user,
|
|
72
|
-
'metrics': response.body.metrics
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
//Setting token and organisationid in comproDLS instance
|
|
76
|
-
self.token = token;
|
|
77
|
-
self.orgId = user.org.id;
|
|
78
|
-
|
|
79
|
-
dfd.resolve(responseObj);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return dfd.promise;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Wiki Link for SDK params
|
|
88
|
-
* https://github.com/comprodls/comprodls-sdk-js/wiki/02_Authentication-and-Tokens#authwithtoken
|
|
89
|
-
*/
|
|
90
|
-
function authWithToken(organizationId, token, options) {
|
|
91
|
-
var self = this;
|
|
92
|
-
var dfd = q.defer();
|
|
93
|
-
|
|
94
|
-
//Validation
|
|
95
|
-
var err = validations.authWithToken(organizationId, token ,options);
|
|
96
|
-
if (err) {
|
|
97
|
-
dfd.reject(err);
|
|
98
|
-
} else {
|
|
99
|
-
|
|
100
|
-
//Setting token and organisationid in comproDLS instance
|
|
101
|
-
self.token = token;
|
|
102
|
-
self.orgId = organizationId;
|
|
103
|
-
|
|
104
|
-
if (options && options.getuserdetails) {
|
|
105
|
-
self.Auth().getUserProfile().then(function(response) {
|
|
106
|
-
var responseObj = {
|
|
107
|
-
'token': self.token,
|
|
108
|
-
'user': response
|
|
109
|
-
};
|
|
110
|
-
dfd.resolve(responseObj);
|
|
111
|
-
}, function(err) {
|
|
112
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
113
|
-
dfd.reject(err);
|
|
114
|
-
});
|
|
115
|
-
} else {
|
|
116
|
-
dfd.resolve(self.token);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return dfd.promise;
|
|
120
|
-
};
|
|
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 Token Manager Module
|
|
23
|
+
* Provides Token managements functions for the SDK
|
|
24
|
+
************************************************************/
|
|
25
|
+
var request = require('superagent');
|
|
26
|
+
var q = require('q');
|
|
27
|
+
|
|
28
|
+
var helpers = require('../helpers');
|
|
29
|
+
var DLSError = helpers.errors.DLSError;
|
|
30
|
+
var validations = require('./validations');
|
|
31
|
+
|
|
32
|
+
exports.authWithExtUser = authWithExtUser;
|
|
33
|
+
exports.authWithToken = authWithToken;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Wiki Link for SDK params
|
|
38
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/02_Authentication-and-Tokens#authwithextuser
|
|
39
|
+
*/
|
|
40
|
+
function authWithExtUser(organizationId, options) {
|
|
41
|
+
var self = this;
|
|
42
|
+
var dfd = q.defer();
|
|
43
|
+
|
|
44
|
+
//Validation
|
|
45
|
+
var err = validations.validateAuthWithExtUser(organizationId, options);
|
|
46
|
+
if (err) {
|
|
47
|
+
dfd.reject(err);
|
|
48
|
+
} else {
|
|
49
|
+
//Passed all Validations, Setup the GET TOKEN API URL.
|
|
50
|
+
var url = this.config.DEFAULT_HOSTS['AUTH'] + this.config.AUTH_API_URLS.getExtUserTokenAPI;
|
|
51
|
+
url = helpers.api.constructAPIUrl(url, {'orgId' : organizationId});
|
|
52
|
+
|
|
53
|
+
//Setup Credentials
|
|
54
|
+
var params = {
|
|
55
|
+
'ext_user_id': options.ext_user_id
|
|
56
|
+
};
|
|
57
|
+
//Call the comproDLS GET TOKEN API
|
|
58
|
+
request.post(url).send(params).end(function(err, response) {
|
|
59
|
+
if (err) {
|
|
60
|
+
//API Error, Construct Standard SDK error response
|
|
61
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
62
|
+
dfd.reject(err);
|
|
63
|
+
} else {
|
|
64
|
+
//Success, Extract the Token & Other useful information
|
|
65
|
+
var token = {
|
|
66
|
+
'access_token': response.body.access_token
|
|
67
|
+
};
|
|
68
|
+
var user = response.body.user;
|
|
69
|
+
var responseObj = {
|
|
70
|
+
'token': token,
|
|
71
|
+
'user': user,
|
|
72
|
+
'metrics': response.body.metrics
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//Setting token and organisationid in comproDLS instance
|
|
76
|
+
self.token = token;
|
|
77
|
+
self.orgId = user.org.id;
|
|
78
|
+
|
|
79
|
+
dfd.resolve(responseObj);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return dfd.promise;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Wiki Link for SDK params
|
|
88
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/02_Authentication-and-Tokens#authwithtoken
|
|
89
|
+
*/
|
|
90
|
+
function authWithToken(organizationId, token, options) {
|
|
91
|
+
var self = this;
|
|
92
|
+
var dfd = q.defer();
|
|
93
|
+
|
|
94
|
+
//Validation
|
|
95
|
+
var err = validations.authWithToken(organizationId, token ,options);
|
|
96
|
+
if (err) {
|
|
97
|
+
dfd.reject(err);
|
|
98
|
+
} else {
|
|
99
|
+
|
|
100
|
+
//Setting token and organisationid in comproDLS instance
|
|
101
|
+
self.token = token;
|
|
102
|
+
self.orgId = organizationId;
|
|
103
|
+
|
|
104
|
+
if (options && options.getuserdetails) {
|
|
105
|
+
self.Auth().getUserProfile().then(function(response) {
|
|
106
|
+
var responseObj = {
|
|
107
|
+
'token': self.token,
|
|
108
|
+
'user': response
|
|
109
|
+
};
|
|
110
|
+
dfd.resolve(responseObj);
|
|
111
|
+
}, function(err) {
|
|
112
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
113
|
+
dfd.reject(err);
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
dfd.resolve(self.token);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return dfd.promise;
|
|
120
|
+
};
|
package/lib/token/validations.js
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
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 Token Module Validations
|
|
23
|
-
* This module contains validations for token manager module.
|
|
24
|
-
************************************************************/
|
|
25
|
-
var validate = require('../helpers').validations.validate;
|
|
26
|
-
|
|
27
|
-
exports.authWithToken = validateAuthWithToken;
|
|
28
|
-
exports.validateAuthWithExtUser = validateAuthWithExtUser;
|
|
29
|
-
|
|
30
|
-
/*********************************
|
|
31
|
-
* Public Function definitions
|
|
32
|
-
**********************************/
|
|
33
|
-
function validateAuthWithToken(organizationId, token ,options) {
|
|
34
|
-
var validate_options = {
|
|
35
|
-
'organization': organizationId,
|
|
36
|
-
'token': token,
|
|
37
|
-
'options': options
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var validate_constraints = {
|
|
41
|
-
'organization': {
|
|
42
|
-
'isString': true,
|
|
43
|
-
'presence': true
|
|
44
|
-
},
|
|
45
|
-
'token': {
|
|
46
|
-
'isObject': true,
|
|
47
|
-
'presence': true,
|
|
48
|
-
'contains': ['access_token']
|
|
49
|
-
},
|
|
50
|
-
'token.access_token': {
|
|
51
|
-
'isString': true,
|
|
52
|
-
'presence': true
|
|
53
|
-
},
|
|
54
|
-
'options': {
|
|
55
|
-
'isObject': true
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return validate(validate_options, validate_constraints);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
function validateAuthWithExtUser(organizationId, options) {
|
|
63
|
-
var validate_options = {
|
|
64
|
-
'organization': organizationId,
|
|
65
|
-
'options': options
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var validate_constraints = {
|
|
69
|
-
'organization': {
|
|
70
|
-
'isString': true,
|
|
71
|
-
'presence': true
|
|
72
|
-
},
|
|
73
|
-
'options': {
|
|
74
|
-
'isObject': true,
|
|
75
|
-
'presence': true,
|
|
76
|
-
'contains': ['ext_user_id']
|
|
77
|
-
},
|
|
78
|
-
'options.ext_user_id': {
|
|
79
|
-
'isString': true,
|
|
80
|
-
'presence': true
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
return validate(validate_options, validate_constraints);
|
|
85
|
-
};
|
|
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 Token Module Validations
|
|
23
|
+
* This module contains validations for token manager module.
|
|
24
|
+
************************************************************/
|
|
25
|
+
var validate = require('../helpers').validations.validate;
|
|
26
|
+
|
|
27
|
+
exports.authWithToken = validateAuthWithToken;
|
|
28
|
+
exports.validateAuthWithExtUser = validateAuthWithExtUser;
|
|
29
|
+
|
|
30
|
+
/*********************************
|
|
31
|
+
* Public Function definitions
|
|
32
|
+
**********************************/
|
|
33
|
+
function validateAuthWithToken(organizationId, token ,options) {
|
|
34
|
+
var validate_options = {
|
|
35
|
+
'organization': organizationId,
|
|
36
|
+
'token': token,
|
|
37
|
+
'options': options
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var validate_constraints = {
|
|
41
|
+
'organization': {
|
|
42
|
+
'isString': true,
|
|
43
|
+
'presence': true
|
|
44
|
+
},
|
|
45
|
+
'token': {
|
|
46
|
+
'isObject': true,
|
|
47
|
+
'presence': true,
|
|
48
|
+
'contains': ['access_token']
|
|
49
|
+
},
|
|
50
|
+
'token.access_token': {
|
|
51
|
+
'isString': true,
|
|
52
|
+
'presence': true
|
|
53
|
+
},
|
|
54
|
+
'options': {
|
|
55
|
+
'isObject': true
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return validate(validate_options, validate_constraints);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
function validateAuthWithExtUser(organizationId, options) {
|
|
63
|
+
var validate_options = {
|
|
64
|
+
'organization': organizationId,
|
|
65
|
+
'options': options
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var validate_constraints = {
|
|
69
|
+
'organization': {
|
|
70
|
+
'isString': true,
|
|
71
|
+
'presence': true
|
|
72
|
+
},
|
|
73
|
+
'options': {
|
|
74
|
+
'isObject': true,
|
|
75
|
+
'presence': true,
|
|
76
|
+
'contains': ['ext_user_id']
|
|
77
|
+
},
|
|
78
|
+
'options.ext_user_id': {
|
|
79
|
+
'isString': true,
|
|
80
|
+
'presence': true
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return validate(validate_options, validate_constraints);
|
|
85
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comprodls-sdk",
|
|
3
3
|
"description": "comproDLS SDK for JavaScript",
|
|
4
|
-
"version": "2.123.2
|
|
4
|
+
"version": "2.123.4-oidc-poc.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Compro Technologies Private Limited",
|
|
7
7
|
"url": "http://www.comprotechnologies.com/"
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://github.com/comprodls/comprodls-sdk-js",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/comprodls/comprodls-sdk-js.git"
|
|
13
|
+
},
|
|
10
14
|
"main": "lib/comprodls.js",
|
|
11
15
|
"engines": {
|
|
12
16
|
"node": ">= 0.8.0"
|