@como/como-client 0.8.1 → 0.8.3

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 CHANGED
@@ -175,7 +175,8 @@ var Como = function () {
175
175
  locationId: locationId,
176
176
  source: source,
177
177
  env_params: (0, _extends3.default)({}, INITIAL_COMO_DATA.env[environmentId]),
178
- tempTokenData: {}
178
+ tempTokenData: {},
179
+ config: {}
179
180
  });
180
181
 
181
182
  updateCredentials = function updateCredentials(creds) {
@@ -201,7 +202,7 @@ var Como = function () {
201
202
  refreshFailed = false;
202
203
 
203
204
  if (!isExpired) {
204
- _context2.next = 30;
205
+ _context2.next = 31;
205
206
  break;
206
207
  }
207
208
 
@@ -212,13 +213,14 @@ var Como = function () {
212
213
  case 20:
213
214
  data = _context2.sent;
214
215
 
216
+ this.comoData.config = data.config;
215
217
  console.log('signOn with isExpired true result:' + (0, _stringify2.default)(data));
216
218
  updateCredentials(data, true);
217
- _context2.next = 30;
219
+ _context2.next = 31;
218
220
  break;
219
221
 
220
- case 25:
221
- _context2.prev = 25;
222
+ case 26:
223
+ _context2.prev = 26;
222
224
  _context2.t0 = _context2['catch'](17);
223
225
 
224
226
  console.error('Failed to refresh token, installationId:' + installationId + ', refreshToken:' + this.comoData.refreshToken + ', locationId:' + locationId + ', source:' + source);
@@ -226,76 +228,78 @@ var Como = function () {
226
228
  initService.logError({ method: 'refreshToken', installationId: installationId, locationId: locationId, source: source, refreshToken: refreshToken, error: _context2.t0.message });
227
229
  refreshFailed = true;
228
230
 
229
- case 30:
231
+ case 31:
230
232
  interval = 0;
231
233
 
232
234
  if (!(refreshFailed || !credExist)) {
233
- _context2.next = 53;
235
+ _context2.next = 55;
234
236
  break;
235
237
  }
236
238
 
237
- case 32:
239
+ case 33:
238
240
  if (!(!credExist && interval < 3000)) {
239
- _context2.next = 51;
241
+ _context2.next = 53;
240
242
  break;
241
243
  }
242
244
 
243
- _context2.prev = 33;
244
- _context2.next = 36;
245
+ _context2.prev = 34;
246
+ _context2.next = 37;
245
247
  return this.comoData.initApi.signOn(installationId, locationId, source);
246
248
 
247
- case 36:
249
+ case 37:
248
250
  _data = _context2.sent;
249
251
 
252
+ this.comoData.config = _data.config;
250
253
  console.log('signOn with refreshFailed result:' + (0, _stringify2.default)(_data));
251
254
  updateCredentials(_data, true);
252
255
  credExist = true;
253
- _context2.next = 49;
256
+ _context2.next = 51;
254
257
  break;
255
258
 
256
- case 42:
257
- _context2.prev = 42;
258
- _context2.t1 = _context2['catch'](33);
259
+ case 44:
260
+ _context2.prev = 44;
261
+ _context2.t1 = _context2['catch'](34);
259
262
 
260
263
  console.error('Failed to signOn, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',interval:' + interval + ', error:' + _context2.t1);
261
264
  interval += 1000;
262
265
  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 });
263
- _context2.next = 49;
266
+ _context2.next = 51;
264
267
  return new _promise2.default(function (r) {
265
268
  return setTimeout(r, interval);
266
269
  });
267
270
 
268
- case 49:
269
- _context2.next = 32;
270
- break;
271
-
272
271
  case 51:
273
- _context2.next = 76;
272
+ _context2.next = 33;
274
273
  break;
275
274
 
276
275
  case 53:
276
+ _context2.next = 79;
277
+ break;
278
+
279
+ case 55:
277
280
  if (isExpired) {
278
- _context2.next = 76;
281
+ _context2.next = 79;
279
282
  break;
280
283
  }
281
284
 
282
285
  signOnSuccessfully = false;
283
286
 
284
- case 55:
287
+ case 57:
285
288
  if (!(!signOnSuccessfully && interval < 3000)) {
286
- _context2.next = 76;
289
+ _context2.next = 79;
287
290
  break;
288
291
  }
289
292
 
290
- _context2.prev = 56;
293
+ _context2.prev = 58;
291
294
 
292
295
  console.log('signOn with installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken);
293
- _context2.next = 60;
296
+ _context2.next = 62;
294
297
  return this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
295
298
 
296
- case 60:
299
+ case 62:
297
300
  _data2 = _context2.sent;
298
301
 
302
+ this.comoData.config = _data2.config;
299
303
  console.log('signOn with result " ' + (0, _stringify2.default)(_data2));
300
304
  if (_data2 && _data2.accessToken) {
301
305
  console.log('signOn- updating credentials');
@@ -305,37 +309,37 @@ var Como = function () {
305
309
  this.comoData.reCaptchaSiteKey = _data2.config.recaptchaSiteKey;
306
310
  }
307
311
  signOnSuccessfully = true;
308
- _context2.next = 74;
312
+ _context2.next = 77;
309
313
  break;
310
314
 
311
- case 67:
312
- _context2.prev = 67;
313
- _context2.t2 = _context2['catch'](56);
315
+ case 70:
316
+ _context2.prev = 70;
317
+ _context2.t2 = _context2['catch'](58);
314
318
 
315
319
  console.error('Failed signOn with accessToken, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken + ', error:' + _context2.t2.message);
316
320
  interval += 1000;
317
321
  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 });
318
- _context2.next = 74;
322
+ _context2.next = 77;
319
323
  return new _promise2.default(function (r) {
320
324
  return setTimeout(r, interval);
321
325
  });
322
326
 
323
- case 74:
324
- _context2.next = 55;
327
+ case 77:
328
+ _context2.next = 57;
325
329
  break;
326
330
 
327
- case 76:
331
+ case 79:
328
332
  if (!this.comoData.token) {
329
333
  this.comoData.token = this.comoData.accessToken;
330
334
  }
331
335
  return _context2.abrupt('return', this.getCredentials());
332
336
 
333
- case 78:
337
+ case 81:
334
338
  case 'end':
335
339
  return _context2.stop();
336
340
  }
337
341
  }
338
- }, _callee2, this, [[17, 25], [33, 42], [56, 67]]);
342
+ }, _callee2, this, [[17, 26], [34, 44], [58, 70]]);
339
343
  }));
340
344
 
341
345
  function init(_x, _x2, _x3) {
@@ -279,7 +279,7 @@ exports.logIn = function (service) {
279
279
  };
280
280
  headers = getHashHeader(params);
281
281
  _context8.next = 4;
282
- return service.post('/auth/v2/auth/logIn', params, { headers: headers });
282
+ return service.post('/auth/v3/auth/logIn', params, { headers: headers });
283
283
 
284
284
  case 4:
285
285
  _ref16 = _context8.sent;
@@ -319,7 +319,7 @@ exports.logInVerify = function (service) {
319
319
  };
320
320
  headers = getHashHeader(params);
321
321
  _context9.next = 4;
322
- return service.post('/auth/v2/auth/logInVerify', params, { headers: headers });
322
+ return service.post('/auth/v3/auth/logInVerify', params, { headers: headers });
323
323
 
324
324
  case 4:
325
325
  _ref18 = _context9.sent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@como/como-client",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Client module for Como's loaylty API",
5
5
  "main": "src/como.js",
6
6
  "scripts": {
package/src/como.js CHANGED
@@ -85,6 +85,7 @@ class Como {
85
85
  ...INITIAL_COMO_DATA.env[environmentId],
86
86
  },
87
87
  tempTokenData: {},
88
+ config: {},
88
89
  };
89
90
 
90
91
  const updateCredentials = (creds, isNew = false) => {
@@ -109,6 +110,7 @@ class Como {
109
110
  if(isExpired){
110
111
  try{
111
112
  const data = await this.comoData.initApi.refreshToken(installationId, refreshToken? refreshToken: 'none', locationId, source);
113
+ this.comoData.config = data.config;
112
114
  console.log(`signOn with isExpired true result:${JSON.stringify(data)}`);
113
115
  updateCredentials(data, true);
114
116
  }catch(e){
@@ -123,6 +125,7 @@ class Como {
123
125
  while(!credExist && interval < 3000){
124
126
  try{
125
127
  const data = await this.comoData.initApi.signOn(installationId, locationId, source);
128
+ this.comoData.config = data.config;
126
129
  console.log(`signOn with refreshFailed result:${JSON.stringify(data)}`);
127
130
  updateCredentials(data, true);
128
131
  credExist = true;
@@ -140,6 +143,7 @@ class Como {
140
143
  try{
141
144
  console.log(`signOn with installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}`);
142
145
  const data = await this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
146
+ this.comoData.config = data.config;
143
147
  console.log(`signOn with result " ${JSON.stringify(data)}`);
144
148
  if(data && data.accessToken){
145
149
  console.log(`signOn- updating credentials`);