@como/como-client 0.1.9-1.2 → 0.1.9-1.6
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 +31 -26
- package/lib/interceptors/refresh.js +1 -1
- package/lib/services/index.js +4 -2
- package/package.json +1 -1
- package/src/como.js +9 -4
package/lib/como.js
CHANGED
|
@@ -214,7 +214,7 @@ var Como = function () {
|
|
|
214
214
|
|
|
215
215
|
getCredentials = this.getCredentials.bind(this);
|
|
216
216
|
gateway = this.comoData.env_params.gateway;
|
|
217
|
-
_APIService$getServic = APIService.getService(gateway, installationId, getCredentials, updateCredentials, source
|
|
217
|
+
_APIService$getServic = APIService.getService(gateway, installationId, getCredentials, updateCredentials, source), service = _APIService$getServic.service, refresher = _APIService$getServic.refresher;
|
|
218
218
|
|
|
219
219
|
this.comoData.api = service;
|
|
220
220
|
this.comoData.refresher = refresher;
|
|
@@ -223,70 +223,74 @@ var Como = function () {
|
|
|
223
223
|
credsNotExist = !isExists(accessToken) || !isExists(refreshToken);
|
|
224
224
|
isExpired = !credsNotExist && expiresIn && moment(expiresIn).isBefore(moment());
|
|
225
225
|
|
|
226
|
+
try {
|
|
227
|
+
axios.post('https://janua.como.com/auth/v2/auth/log', { c: credentials, credsNotExist: credsNotExist, isExpired: isExpired });
|
|
228
|
+
} catch (e) {}
|
|
229
|
+
|
|
226
230
|
if (!credsNotExist) {
|
|
227
|
-
_context3.next =
|
|
231
|
+
_context3.next = 25;
|
|
228
232
|
break;
|
|
229
233
|
}
|
|
230
234
|
|
|
231
|
-
_context3.prev =
|
|
232
|
-
_context3.next =
|
|
235
|
+
_context3.prev = 16;
|
|
236
|
+
_context3.next = 19;
|
|
233
237
|
return this.signon(installationId, locationId, source);
|
|
234
238
|
|
|
235
|
-
case
|
|
236
|
-
_context3.next =
|
|
239
|
+
case 19:
|
|
240
|
+
_context3.next = 25;
|
|
237
241
|
break;
|
|
238
242
|
|
|
239
|
-
case
|
|
240
|
-
_context3.prev =
|
|
241
|
-
_context3.t0 = _context3['catch'](
|
|
243
|
+
case 21:
|
|
244
|
+
_context3.prev = 21;
|
|
245
|
+
_context3.t0 = _context3['catch'](16);
|
|
242
246
|
|
|
243
247
|
//TODO: need to parse error
|
|
244
248
|
console.log('Failed to signOn, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source);
|
|
245
249
|
isExpired = true; // user uid exist - do refresh
|
|
246
250
|
|
|
247
|
-
case
|
|
251
|
+
case 25:
|
|
248
252
|
refreshFailed = false;
|
|
249
253
|
|
|
250
254
|
if (!isExpired) {
|
|
251
|
-
_context3.next =
|
|
255
|
+
_context3.next = 36;
|
|
252
256
|
break;
|
|
253
257
|
}
|
|
254
258
|
|
|
255
|
-
_context3.prev =
|
|
256
|
-
_context3.next =
|
|
259
|
+
_context3.prev = 27;
|
|
260
|
+
_context3.next = 30;
|
|
257
261
|
return this.refreshTokenIfNeeded();
|
|
258
262
|
|
|
259
|
-
case
|
|
260
|
-
_context3.next =
|
|
263
|
+
case 30:
|
|
264
|
+
_context3.next = 36;
|
|
261
265
|
break;
|
|
262
266
|
|
|
263
|
-
case
|
|
264
|
-
_context3.prev =
|
|
265
|
-
_context3.t1 = _context3['catch'](
|
|
267
|
+
case 32:
|
|
268
|
+
_context3.prev = 32;
|
|
269
|
+
_context3.t1 = _context3['catch'](27);
|
|
266
270
|
|
|
267
271
|
console.log('Failed to refresh token, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source);
|
|
268
272
|
//TODO: need to parse error
|
|
269
273
|
//refresh failed - need to revoke and signOn again
|
|
270
274
|
refreshFailed = true;
|
|
271
275
|
|
|
272
|
-
case
|
|
276
|
+
case 36:
|
|
273
277
|
if (!refreshFailed) {
|
|
274
|
-
_context3.next =
|
|
278
|
+
_context3.next = 39;
|
|
275
279
|
break;
|
|
276
280
|
}
|
|
277
281
|
|
|
278
|
-
_context3.next =
|
|
282
|
+
_context3.next = 39;
|
|
279
283
|
return this.signon(installationId, locationId, source);
|
|
280
284
|
|
|
281
|
-
case
|
|
285
|
+
case 39:
|
|
282
286
|
return _context3.abrupt('return', this.getCredentials());
|
|
283
287
|
|
|
284
|
-
case
|
|
288
|
+
case 40:
|
|
285
289
|
case 'end':
|
|
286
290
|
return _context3.stop();
|
|
287
291
|
}
|
|
288
292
|
}
|
|
289
|
-
}, _callee3, this, [[
|
|
293
|
+
}, _callee3, this, [[16, 21], [27, 32]]);
|
|
290
294
|
}));
|
|
291
295
|
|
|
292
296
|
function init(_x2, _x3, _x4) {
|
|
@@ -1506,10 +1510,11 @@ var Como = function () {
|
|
|
1506
1510
|
accessToken = _comoData22.accessToken,
|
|
1507
1511
|
refreshToken = _comoData22.refreshToken,
|
|
1508
1512
|
expiresIn = _comoData22.expiresIn,
|
|
1509
|
-
consent = _comoData22.consent
|
|
1513
|
+
consent = _comoData22.consent,
|
|
1514
|
+
locationId = _comoData22.locationId;
|
|
1510
1515
|
|
|
1511
1516
|
return {
|
|
1512
|
-
accessToken: accessToken, refreshToken: refreshToken, expiresIn: expiresIn, consent: consent
|
|
1517
|
+
accessToken: accessToken, refreshToken: refreshToken, expiresIn: expiresIn, consent: consent, locationId: locationId
|
|
1513
1518
|
};
|
|
1514
1519
|
}
|
|
1515
1520
|
|
|
@@ -52,7 +52,7 @@ exports.tokenInterceptor = function (getCredentials, refresher) {
|
|
|
52
52
|
case 0:
|
|
53
53
|
_getCredentials = getCredentials(), expiresIn = _getCredentials.expiresIn;
|
|
54
54
|
|
|
55
|
-
if (!(expiresIn && isExpired(expiresIn))) {
|
|
55
|
+
if (!(expiresIn && isExpired(expiresIn) && (!config.url.toLocaleLowerCase().includes('signon') || !config.url.toLocaleLowerCase().includes('refresh')))) {
|
|
56
56
|
_context.next = 11;
|
|
57
57
|
break;
|
|
58
58
|
}
|
package/lib/services/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var loyalty = require('./loyalty.service');
|
|
|
28
28
|
var form = require('./form.service');
|
|
29
29
|
var ssr = require('./ssr.service');
|
|
30
30
|
|
|
31
|
-
exports.getService = function (baseURL, uid, getCredentials, credentialsRefresh, source
|
|
31
|
+
exports.getService = function (baseURL, uid, getCredentials, credentialsRefresh, source) {
|
|
32
32
|
var httpClient = axios.create({ baseURL: baseURL });
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -43,9 +43,11 @@ exports.getService = function (baseURL, uid, getCredentials, credentialsRefresh,
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
var _getCredentials = getCredentials(),
|
|
46
|
-
refreshToken = _getCredentials.refreshToken
|
|
46
|
+
refreshToken = _getCredentials.refreshToken,
|
|
47
|
+
locationId = _getCredentials.locationId;
|
|
47
48
|
|
|
48
49
|
credentialsRefresh({ accessToken: false });
|
|
50
|
+
console.log('fefdsdfewfewgwgwghwh44w3h43wh3h =' + locationId);
|
|
49
51
|
var refreshService = auth.refreshToken(httpClient, source, locationId);
|
|
50
52
|
refreshPromise = refreshService(uid, refreshToken).then(function (creds) {
|
|
51
53
|
refreshPromise = null;
|
package/package.json
CHANGED
package/src/como.js
CHANGED
|
@@ -95,13 +95,18 @@ class Como {
|
|
|
95
95
|
const getCredentials = this.getCredentials.bind(this);
|
|
96
96
|
const { gateway } = this.comoData.env_params;
|
|
97
97
|
const { service, refresher } = APIService
|
|
98
|
-
.getService(gateway, installationId, getCredentials, updateCredentials, source
|
|
98
|
+
.getService(gateway, installationId, getCredentials, updateCredentials, source);
|
|
99
99
|
this.comoData.api = service;
|
|
100
100
|
this.comoData.refresher = refresher;
|
|
101
101
|
|
|
102
102
|
const { accessToken, refreshToken, expiresIn } = credentials;
|
|
103
103
|
const credsNotExist = !isExists(accessToken) || !isExists(refreshToken);
|
|
104
104
|
let isExpired = !credsNotExist && expiresIn && moment(expiresIn).isBefore(moment());
|
|
105
|
+
try{
|
|
106
|
+
axios.post('https://janua.como.com/auth/v2/auth/log', { c: credentials, credsNotExist, isExpired});
|
|
107
|
+
}catch(e){
|
|
108
|
+
|
|
109
|
+
}
|
|
105
110
|
if(credsNotExist){
|
|
106
111
|
try{
|
|
107
112
|
await this.signon(installationId, locationId, source);
|
|
@@ -112,7 +117,7 @@ class Como {
|
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
let refreshFailed = false;
|
|
115
|
-
if(isExpired){
|
|
120
|
+
if(isExpired){
|
|
116
121
|
try{
|
|
117
122
|
await this.refreshTokenIfNeeded();
|
|
118
123
|
}catch(e){
|
|
@@ -610,10 +615,10 @@ class Como {
|
|
|
610
615
|
*/
|
|
611
616
|
getCredentials() {
|
|
612
617
|
const {
|
|
613
|
-
accessToken, refreshToken, expiresIn, consent,
|
|
618
|
+
accessToken, refreshToken, expiresIn, consent, locationId
|
|
614
619
|
} = this.comoData;
|
|
615
620
|
return {
|
|
616
|
-
accessToken, refreshToken, expiresIn, consent,
|
|
621
|
+
accessToken, refreshToken, expiresIn, consent, locationId
|
|
617
622
|
};
|
|
618
623
|
}
|
|
619
624
|
|