@como/como-client 0.7.52 → 0.7.53

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 (3) hide show
  1. package/lib/como.js +33 -14
  2. package/package.json +1 -1
  3. package/src/como.js +17 -10
package/lib/como.js CHANGED
@@ -148,7 +148,7 @@ var Como = function () {
148
148
 
149
149
  var enableSignon = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
150
150
 
151
- var isExists, environmentId, locationId, installationId, source, updateCredentials, getCredentials, gateway, _APIService$getServic, service, refresher, initService, accessToken, refreshToken, expiresIn, credExist, isExpired, refreshFailed, data, interval, _data, _data2;
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;
152
152
 
153
153
  return _regenerator2.default.wrap(function _callee2$(_context2) {
154
154
  while (1) {
@@ -255,7 +255,7 @@ var Como = function () {
255
255
 
256
256
  console.error('Failed to signOn, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',interval:' + interval + ', error:' + _context2.t1);
257
257
  interval += 1000;
258
- initService.logError({ method: 'signOn', installationId: installationId, locationId: locationId, source: source, refreshToken: refreshToken, interval: interval, error: _context2.t1.message });
258
+ initService.logError({ method: 'signOn no accessToken', accessToken: accessToken, isExpired: isExpired, refreshFailed: refreshFailed, credExist: credExist, installationId: installationId, locationId: locationId, source: source, refreshToken: refreshToken, interval: interval, error: _context2.t1.message });
259
259
  _context2.next = 47;
260
260
  return new _promise2.default(function (r) {
261
261
  return setTimeout(r, interval);
@@ -266,22 +266,30 @@ var Como = function () {
266
266
  break;
267
267
 
268
268
  case 49:
269
- _context2.next = 64;
269
+ _context2.next = 73;
270
270
  break;
271
271
 
272
272
  case 51:
273
273
  if (isExpired) {
274
- _context2.next = 64;
274
+ _context2.next = 73;
275
275
  break;
276
276
  }
277
277
 
278
- _context2.prev = 52;
278
+ signOnSuccessfully = false;
279
+
280
+ case 53:
281
+ if (!(!signOnSuccessfully && interval < 3000)) {
282
+ _context2.next = 73;
283
+ break;
284
+ }
285
+
286
+ _context2.prev = 54;
279
287
 
280
288
  console.log('signOn with installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken);
281
- _context2.next = 56;
289
+ _context2.next = 58;
282
290
  return this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
283
291
 
284
- case 56:
292
+ case 58:
285
293
  _data2 = _context2.sent;
286
294
 
287
295
  console.log('signOn with result " ' + (0, _stringify2.default)(_data2));
@@ -289,27 +297,38 @@ var Como = function () {
289
297
  console.log('signOn- updating credentials');
290
298
  updateCredentials(_data2, true);
291
299
  }
292
- _context2.next = 64;
300
+ signOnSuccessfully = true;
301
+ _context2.next = 71;
293
302
  break;
294
303
 
295
- case 61:
296
- _context2.prev = 61;
297
- _context2.t2 = _context2['catch'](52);
304
+ case 64:
305
+ _context2.prev = 64;
306
+ _context2.t2 = _context2['catch'](54);
298
307
 
299
308
  console.error('Failed signOn with accessToken, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken + ', error:' + _context2.t2.message);
309
+ interval += 1000;
310
+ initService.logError({ method: 'signOn with credentials', accessToken: accessToken, isExpired: isExpired, refreshFailed: refreshFailed, credExist: credExist, installationId: installationId, locationId: locationId, source: source, refreshToken: refreshToken, interval: interval, error: _context2.t2.message });
311
+ _context2.next = 71;
312
+ return new _promise2.default(function (r) {
313
+ return setTimeout(r, interval);
314
+ });
300
315
 
301
- case 64:
316
+ case 71:
317
+ _context2.next = 53;
318
+ break;
319
+
320
+ case 73:
302
321
  if (!this.comoData.token) {
303
322
  this.comoData.token = this.comoData.accessToken;
304
323
  }
305
324
  return _context2.abrupt('return', this.getCredentials());
306
325
 
307
- case 66:
326
+ case 75:
308
327
  case 'end':
309
328
  return _context2.stop();
310
329
  }
311
330
  }
312
- }, _callee2, this, [[17, 24], [32, 40], [52, 61]]);
331
+ }, _callee2, this, [[17, 24], [32, 40], [54, 64]]);
313
332
  }));
314
333
 
315
334
  function init(_x, _x2, _x3) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@como/como-client",
3
- "version": "0.7.52",
3
+ "version": "0.7.53",
4
4
  "description": "Client module for Como's loaylty API",
5
5
  "main": "src/como.js",
6
6
  "scripts": {
package/src/como.js CHANGED
@@ -125,22 +125,29 @@ class Como {
125
125
  }catch(e){
126
126
  console.error(`Failed to signOn, installationId:${installationId}, locationId:${locationId}, source:${source},interval:${interval}, error:${e}`);
127
127
  interval += 1000;
128
- initService.logError({method: 'signOn', installationId, locationId, source, refreshToken, interval, error : e.message});
128
+ initService.logError({method: 'signOn no accessToken', accessToken, isExpired, refreshFailed , credExist, installationId, locationId, source, refreshToken, interval, error : e.message});
129
129
  await new Promise(r => setTimeout(r, interval));
130
130
  }
131
131
  }
132
132
  }
133
133
  else if(!isExpired){
134
- try{
135
- console.log(`signOn with installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}`);
136
- const data = await this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
137
- console.log(`signOn with result " ${JSON.stringify(data)}`);
138
- if(data && data.accessToken){
139
- console.log(`signOn- updating credentials`);
140
- updateCredentials(data, true);
134
+ let signOnSuccessfully = false;
135
+ while(!signOnSuccessfully && interval < 3000){
136
+ try{
137
+ console.log(`signOn with installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}`);
138
+ const data = await this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
139
+ console.log(`signOn with result " ${JSON.stringify(data)}`);
140
+ if(data && data.accessToken){
141
+ console.log(`signOn- updating credentials`);
142
+ updateCredentials(data, true);
143
+ }
144
+ signOnSuccessfully = true;
145
+ }catch(e){
146
+ console.error(`Failed signOn with accessToken, installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}, error:${e.message}`);
147
+ interval += 1000;
148
+ initService.logError({method: 'signOn with credentials', accessToken, isExpired, refreshFailed , credExist, installationId, locationId, source, refreshToken, interval, error : e.message});
149
+ await new Promise(r => setTimeout(r, interval));
141
150
  }
142
- }catch(e){
143
- console.error(`Failed signOn with accessToken, installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}, error:${e.message}`);
144
151
  }
145
152
  }
146
153
  if(!this.comoData.token){