@como/como-client 0.7.55 → 0.7.59
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/lib/como.js +6 -4
- package/lib/services/index.js +7 -4
- package/package.json +1 -1
- package/src/como.js +5 -3
package/lib/como.js
CHANGED
|
@@ -42,6 +42,8 @@ var comoExternalUrlTranslator = require('./utils/comoExternalUrlTranslator');
|
|
|
42
42
|
var resourceNames = require('./constants/resourceNames');
|
|
43
43
|
var urlsUtils = require('./utils/urls');
|
|
44
44
|
|
|
45
|
+
var internalServices = ['como_connect'];
|
|
46
|
+
|
|
45
47
|
var INITIAL_COMO_DATA = {
|
|
46
48
|
env: environmentConfig,
|
|
47
49
|
token: null,
|
|
@@ -148,7 +150,7 @@ var Como = function () {
|
|
|
148
150
|
|
|
149
151
|
var enableSignon = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
150
152
|
|
|
151
|
-
var isExists, environmentId, locationId, installationId, source, updateCredentials, getCredentials, gateway, _APIService$getServic, service, refresher, initService, accessToken, refreshToken, expiresIn, credExist, isExpired, refreshFailed, data, interval, _data, signOnSuccessfully, _data2;
|
|
153
|
+
var isExists, environmentId, locationId, installationId, source, binaryVersion, phoenixVersion, updateCredentials, getCredentials, gateway, _APIService$getServic, service, refresher, initService, accessToken, refreshToken, expiresIn, credExist, isExpired, refreshFailed, data, interval, _data, signOnSuccessfully, _data2;
|
|
152
154
|
|
|
153
155
|
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
154
156
|
while (1) {
|
|
@@ -158,7 +160,7 @@ var Como = function () {
|
|
|
158
160
|
return !ramda.isNil(x) && !ramda.isEmpty(x);
|
|
159
161
|
};
|
|
160
162
|
|
|
161
|
-
environmentId = environment.id, locationId = environment.locationId, installationId = environment.installationId, source = environment.source;
|
|
163
|
+
environmentId = environment.id, locationId = environment.locationId, installationId = environment.installationId, source = environment.source, binaryVersion = environment.binaryVersion, phoenixVersion = environment.phoenixVersion;
|
|
162
164
|
|
|
163
165
|
if (!(!isExists(environmentId) || !isExists(locationId) || !isExists(installationId))) {
|
|
164
166
|
_context2.next = 4;
|
|
@@ -187,14 +189,14 @@ var Como = function () {
|
|
|
187
189
|
|
|
188
190
|
getCredentials = this.getCredentials.bind(this);
|
|
189
191
|
gateway = this.comoData.env_params.gateway;
|
|
190
|
-
_APIService$getServic = APIService.getService(gateway, installationId, getCredentials, updateCredentials, source), service = _APIService$getServic.service, refresher = _APIService$getServic.refresher, initService = _APIService$getServic.initService;
|
|
192
|
+
_APIService$getServic = APIService.getService(gateway, installationId, getCredentials, updateCredentials, source, binaryVersion, phoenixVersion), service = _APIService$getServic.service, refresher = _APIService$getServic.refresher, initService = _APIService$getServic.initService;
|
|
191
193
|
|
|
192
194
|
this.comoData.api = service;
|
|
193
195
|
this.comoData.initApi = initService;
|
|
194
196
|
this.comoData.refresher = refresher;
|
|
195
197
|
|
|
196
198
|
accessToken = credentials.accessToken, refreshToken = credentials.refreshToken, expiresIn = credentials.expiresIn;
|
|
197
|
-
credExist = isExists(accessToken) && isExists(refreshToken);
|
|
199
|
+
credExist = isExists(accessToken) && isExists(refreshToken) || internalServices.includes(source);
|
|
198
200
|
isExpired = credExist && expiresIn && moment(expiresIn).isBefore(moment());
|
|
199
201
|
refreshFailed = false;
|
|
200
202
|
|
package/lib/services/index.js
CHANGED
|
@@ -33,7 +33,10 @@ var ssr = require('./ssr.service');
|
|
|
33
33
|
var log = require('./log.service');
|
|
34
34
|
|
|
35
35
|
exports.getService = function (baseURL, uid, getCredentials, credentialsRefresh, source) {
|
|
36
|
-
var
|
|
36
|
+
var binaryVersion = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'not-defined';
|
|
37
|
+
var phoenixVersion = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'not-defined';
|
|
38
|
+
|
|
39
|
+
var httpClient = axios.create({ baseURL: baseURL, headers: { 'x-comojs-version': version, 'x-binary-version': binaryVersion, 'x-phoenix-version': phoenixVersion } });
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* TODO: Make refresher prettier.
|
|
@@ -70,13 +73,13 @@ exports.getService = function (baseURL, uid, getCredentials, credentialsRefresh,
|
|
|
70
73
|
prev[curr] = apiCalls[curr](httpClient); // eslint-disable-line no-param-reassign
|
|
71
74
|
return prev;
|
|
72
75
|
}, {});
|
|
73
|
-
var initService = getInitApiCalles(baseURL);
|
|
76
|
+
var initService = getInitApiCalles(baseURL, binaryVersion, phoenixVersion);
|
|
74
77
|
|
|
75
78
|
return { initService: initService, service: service, refresher: refresher };
|
|
76
79
|
};
|
|
77
80
|
|
|
78
|
-
function getInitApiCalles(baseURL) {
|
|
79
|
-
var httpInitClient = axios.create({ baseURL: baseURL });
|
|
81
|
+
function getInitApiCalles(baseURL, binaryVersion, phoenixVersion) {
|
|
82
|
+
var httpInitClient = axios.create({ baseURL: baseURL, headers: { 'x-comojs-version': version, 'x-binary-version': binaryVersion, 'x-phoenix-version': phoenixVersion } });
|
|
80
83
|
var initApiCalls = { signOn: auth.signOn, refreshToken: auth.refreshToken, logError: log.logError };
|
|
81
84
|
return (0, _keys2.default)(initApiCalls).reduce(function (prev, curr) {
|
|
82
85
|
prev[curr] = initApiCalls[curr](httpInitClient); // eslint-disable-line no-param-reassign
|
package/package.json
CHANGED
package/src/como.js
CHANGED
|
@@ -6,6 +6,8 @@ const comoExternalUrlTranslator = require('./utils/comoExternalUrlTranslator');
|
|
|
6
6
|
const resourceNames = require('./constants/resourceNames');
|
|
7
7
|
const urlsUtils = require('./utils/urls');
|
|
8
8
|
|
|
9
|
+
const internalServices = ['como_connect'];
|
|
10
|
+
|
|
9
11
|
const INITIAL_COMO_DATA = {
|
|
10
12
|
env: environmentConfig,
|
|
11
13
|
token: null,
|
|
@@ -69,7 +71,7 @@ class Como {
|
|
|
69
71
|
*/
|
|
70
72
|
async init(environment, credentials, refreshCallback, enableSignon = true) {
|
|
71
73
|
const isExists = (x => !ramda.isNil(x) && !ramda.isEmpty(x));
|
|
72
|
-
const { id: environmentId, locationId, installationId, source } = environment;
|
|
74
|
+
const { id: environmentId, locationId, installationId, source, binaryVersion, phoenixVersion } = environment;
|
|
73
75
|
if (!isExists(environmentId) || !isExists(locationId) || !isExists(installationId)) {
|
|
74
76
|
throw new Error(`missing parameters: ${environment}`);
|
|
75
77
|
}
|
|
@@ -95,13 +97,13 @@ class Como {
|
|
|
95
97
|
const getCredentials = this.getCredentials.bind(this);
|
|
96
98
|
const { gateway } = this.comoData.env_params;
|
|
97
99
|
const { service, refresher, initService } = APIService
|
|
98
|
-
.getService(gateway, installationId, getCredentials, updateCredentials, source);
|
|
100
|
+
.getService(gateway, installationId, getCredentials, updateCredentials, source, binaryVersion, phoenixVersion);
|
|
99
101
|
this.comoData.api = service;
|
|
100
102
|
this.comoData.initApi = initService;
|
|
101
103
|
this.comoData.refresher = refresher;
|
|
102
104
|
|
|
103
105
|
const { accessToken, refreshToken, expiresIn } = credentials;
|
|
104
|
-
let credExist = isExists(accessToken) && isExists(refreshToken);
|
|
106
|
+
let credExist = isExists(accessToken) && isExists(refreshToken) || internalServices.includes(source);
|
|
105
107
|
let isExpired = credExist && expiresIn && moment(expiresIn).isBefore(moment());
|
|
106
108
|
let refreshFailed = false;
|
|
107
109
|
if(isExpired){
|