@como/como-client 0.7.99 → 0.8.1

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 +203 -179
  2. package/package.json +1 -1
  3. package/src/como.js +9 -4
package/lib/como.js CHANGED
@@ -4,14 +4,14 @@ var _keys = require('babel-runtime/core-js/object/keys');
4
4
 
5
5
  var _keys2 = _interopRequireDefault(_keys);
6
6
 
7
- var _stringify = require('babel-runtime/core-js/json/stringify');
8
-
9
- var _stringify2 = _interopRequireDefault(_stringify);
10
-
11
7
  var _promise = require('babel-runtime/core-js/promise');
12
8
 
13
9
  var _promise2 = _interopRequireDefault(_promise);
14
10
 
11
+ var _stringify = require('babel-runtime/core-js/json/stringify');
12
+
13
+ var _stringify2 = _interopRequireDefault(_stringify);
14
+
15
15
  var _extends2 = require('babel-runtime/helpers/extends');
16
16
 
17
17
  var _extends3 = _interopRequireDefault(_extends2);
@@ -201,7 +201,7 @@ var Como = function () {
201
201
  refreshFailed = false;
202
202
 
203
203
  if (!isExpired) {
204
- _context2.next = 29;
204
+ _context2.next = 30;
205
205
  break;
206
206
  }
207
207
 
@@ -212,12 +212,13 @@ var Como = function () {
212
212
  case 20:
213
213
  data = _context2.sent;
214
214
 
215
+ console.log('signOn with isExpired true result:' + (0, _stringify2.default)(data));
215
216
  updateCredentials(data, true);
216
- _context2.next = 29;
217
+ _context2.next = 30;
217
218
  break;
218
219
 
219
- case 24:
220
- _context2.prev = 24;
220
+ case 25:
221
+ _context2.prev = 25;
221
222
  _context2.t0 = _context2['catch'](17);
222
223
 
223
224
  console.error('Failed to refresh token, installationId:' + installationId + ', refreshToken:' + this.comoData.refreshToken + ', locationId:' + locationId + ', source:' + source);
@@ -225,73 +226,74 @@ var Como = function () {
225
226
  initService.logError({ method: 'refreshToken', installationId: installationId, locationId: locationId, source: source, refreshToken: refreshToken, error: _context2.t0.message });
226
227
  refreshFailed = true;
227
228
 
228
- case 29:
229
+ case 30:
229
230
  interval = 0;
230
231
 
231
232
  if (!(refreshFailed || !credExist)) {
232
- _context2.next = 51;
233
+ _context2.next = 53;
233
234
  break;
234
235
  }
235
236
 
236
- case 31:
237
+ case 32:
237
238
  if (!(!credExist && interval < 3000)) {
238
- _context2.next = 49;
239
+ _context2.next = 51;
239
240
  break;
240
241
  }
241
242
 
242
- _context2.prev = 32;
243
- _context2.next = 35;
243
+ _context2.prev = 33;
244
+ _context2.next = 36;
244
245
  return this.comoData.initApi.signOn(installationId, locationId, source);
245
246
 
246
- case 35:
247
+ case 36:
247
248
  _data = _context2.sent;
248
249
 
250
+ console.log('signOn with refreshFailed result:' + (0, _stringify2.default)(_data));
249
251
  updateCredentials(_data, true);
250
252
  credExist = true;
251
- _context2.next = 47;
253
+ _context2.next = 49;
252
254
  break;
253
255
 
254
- case 40:
255
- _context2.prev = 40;
256
- _context2.t1 = _context2['catch'](32);
256
+ case 42:
257
+ _context2.prev = 42;
258
+ _context2.t1 = _context2['catch'](33);
257
259
 
258
260
  console.error('Failed to signOn, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',interval:' + interval + ', error:' + _context2.t1);
259
261
  interval += 1000;
260
262
  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 });
261
- _context2.next = 47;
263
+ _context2.next = 49;
262
264
  return new _promise2.default(function (r) {
263
265
  return setTimeout(r, interval);
264
266
  });
265
267
 
266
- case 47:
267
- _context2.next = 31;
268
- break;
269
-
270
268
  case 49:
271
- _context2.next = 74;
269
+ _context2.next = 32;
272
270
  break;
273
271
 
274
272
  case 51:
273
+ _context2.next = 76;
274
+ break;
275
+
276
+ case 53:
275
277
  if (isExpired) {
276
- _context2.next = 74;
278
+ _context2.next = 76;
277
279
  break;
278
280
  }
279
281
 
280
282
  signOnSuccessfully = false;
281
283
 
282
- case 53:
284
+ case 55:
283
285
  if (!(!signOnSuccessfully && interval < 3000)) {
284
- _context2.next = 74;
286
+ _context2.next = 76;
285
287
  break;
286
288
  }
287
289
 
288
- _context2.prev = 54;
290
+ _context2.prev = 56;
289
291
 
290
292
  console.log('signOn with installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken);
291
- _context2.next = 58;
293
+ _context2.next = 60;
292
294
  return this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
293
295
 
294
- case 58:
296
+ case 60:
295
297
  _data2 = _context2.sent;
296
298
 
297
299
  console.log('signOn with result " ' + (0, _stringify2.default)(_data2));
@@ -303,37 +305,37 @@ var Como = function () {
303
305
  this.comoData.reCaptchaSiteKey = _data2.config.recaptchaSiteKey;
304
306
  }
305
307
  signOnSuccessfully = true;
306
- _context2.next = 72;
308
+ _context2.next = 74;
307
309
  break;
308
310
 
309
- case 65:
310
- _context2.prev = 65;
311
- _context2.t2 = _context2['catch'](54);
311
+ case 67:
312
+ _context2.prev = 67;
313
+ _context2.t2 = _context2['catch'](56);
312
314
 
313
315
  console.error('Failed signOn with accessToken, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken + ', error:' + _context2.t2.message);
314
316
  interval += 1000;
315
317
  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 });
316
- _context2.next = 72;
318
+ _context2.next = 74;
317
319
  return new _promise2.default(function (r) {
318
320
  return setTimeout(r, interval);
319
321
  });
320
322
 
321
- case 72:
322
- _context2.next = 53;
323
+ case 74:
324
+ _context2.next = 55;
323
325
  break;
324
326
 
325
- case 74:
327
+ case 76:
326
328
  if (!this.comoData.token) {
327
329
  this.comoData.token = this.comoData.accessToken;
328
330
  }
329
331
  return _context2.abrupt('return', this.getCredentials());
330
332
 
331
- case 76:
333
+ case 78:
332
334
  case 'end':
333
335
  return _context2.stop();
334
336
  }
335
337
  }
336
- }, _callee2, this, [[17, 24], [32, 40], [54, 65]]);
338
+ }, _callee2, this, [[17, 25], [33, 42], [56, 67]]);
337
339
  }));
338
340
 
339
341
  function init(_x, _x2, _x3) {
@@ -362,7 +364,7 @@ var Como = function () {
362
364
  this.comoData.token = credentials.accessToken;
363
365
  this.comoData.refreshToken = credentials.refreshToken;
364
366
  this.comoData.expiresIn = credentials.expiresIn;
365
- if (credentials.config) {
367
+ if (credentials && credentials.config) {
366
368
  this.comoData.reCaptchaSiteKey = credentials.config.recaptchaSiteKey;
367
369
  if (credentials.config.recaptcha) {
368
370
  this.comoData.recaptchaConfig = credentials.config.recaptcha;
@@ -1652,11 +1654,10 @@ var Como = function () {
1652
1654
  refreshToken = _comoData22.refreshToken,
1653
1655
  expiresIn = _comoData22.expiresIn,
1654
1656
  consent = _comoData22.consent,
1655
- locationId = _comoData22.locationId,
1656
- recaptchaConfig = _comoData22.recaptchaConfig;
1657
+ locationId = _comoData22.locationId;
1657
1658
 
1658
1659
  return {
1659
- accessToken: accessToken, refreshToken: refreshToken, expiresIn: expiresIn, consent: consent, locationId: locationId, recaptchaConfig: recaptchaConfig
1660
+ accessToken: accessToken, refreshToken: refreshToken, expiresIn: expiresIn, consent: consent, locationId: locationId
1660
1661
  };
1661
1662
  }
1662
1663
 
@@ -1709,9 +1710,32 @@ var Como = function () {
1709
1710
 
1710
1711
  }, {
1711
1712
  key: 'getRecaptchaConfig',
1712
- value: function getRecaptchaConfig() {
1713
- return { reCaptchaSiteKey: this.comoData.reCaptchaSiteKey, baseUrl: this.comoData.env_params.gateway, recaptchaConfig: this.comoData.recaptchaConfig };
1714
- }
1713
+ value: function () {
1714
+ var _ref28 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee27() {
1715
+ return _regenerator2.default.wrap(function _callee27$(_context27) {
1716
+ while (1) {
1717
+ switch (_context27.prev = _context27.next) {
1718
+ case 0:
1719
+ _context27.next = 2;
1720
+ return this.refreshTokenIfNeeded();
1721
+
1722
+ case 2:
1723
+ return _context27.abrupt('return', this.comoData.recaptchaConfig);
1724
+
1725
+ case 3:
1726
+ case 'end':
1727
+ return _context27.stop();
1728
+ }
1729
+ }
1730
+ }, _callee27, this);
1731
+ }));
1732
+
1733
+ function getRecaptchaConfig() {
1734
+ return _ref28.apply(this, arguments);
1735
+ }
1736
+
1737
+ return getRecaptchaConfig;
1738
+ }()
1715
1739
 
1716
1740
  /**
1717
1741
  * Returns the location specific registration web url
@@ -1720,33 +1744,33 @@ var Como = function () {
1720
1744
  }, {
1721
1745
  key: 'getRegistrationUrl',
1722
1746
  value: function () {
1723
- var _ref28 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee27(overrides) {
1747
+ var _ref29 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee28(overrides) {
1724
1748
  var _comoData23, token, installationId, locationId, env;
1725
1749
 
1726
- return _regenerator2.default.wrap(function _callee27$(_context27) {
1750
+ return _regenerator2.default.wrap(function _callee28$(_context28) {
1727
1751
  while (1) {
1728
- switch (_context27.prev = _context27.next) {
1752
+ switch (_context28.prev = _context28.next) {
1729
1753
  case 0:
1730
- _context27.next = 2;
1754
+ _context28.next = 2;
1731
1755
  return this.refreshTokenIfNeeded();
1732
1756
 
1733
1757
  case 2:
1734
1758
  _comoData23 = this.comoData, token = _comoData23.token, installationId = _comoData23.installationId, locationId = _comoData23.locationId, env = _comoData23.env_params;
1735
- return _context27.abrupt('return', urlsUtils.appendQuery(env.app_modules_root + '/register?token=' + token + '&locationid=' + locationId, (0, _extends3.default)({}, this.getCredentials(), {
1759
+ return _context28.abrupt('return', urlsUtils.appendQuery(env.app_modules_root + '/register?token=' + token + '&locationid=' + locationId, (0, _extends3.default)({}, this.getCredentials(), {
1736
1760
  installationId: installationId,
1737
1761
  disableSuccessScreen: 'true'
1738
1762
  }, overrides)));
1739
1763
 
1740
1764
  case 4:
1741
1765
  case 'end':
1742
- return _context27.stop();
1766
+ return _context28.stop();
1743
1767
  }
1744
1768
  }
1745
- }, _callee27, this);
1769
+ }, _callee28, this);
1746
1770
  }));
1747
1771
 
1748
1772
  function getRegistrationUrl(_x49) {
1749
- return _ref28.apply(this, arguments);
1773
+ return _ref29.apply(this, arguments);
1750
1774
  }
1751
1775
 
1752
1776
  return getRegistrationUrl;
@@ -1759,33 +1783,33 @@ var Como = function () {
1759
1783
  }, {
1760
1784
  key: 'getProfileUrl',
1761
1785
  value: function () {
1762
- var _ref29 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee28(overrides) {
1786
+ var _ref30 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee29(overrides) {
1763
1787
  var _comoData24, token, installationId, locationId, env;
1764
1788
 
1765
- return _regenerator2.default.wrap(function _callee28$(_context28) {
1789
+ return _regenerator2.default.wrap(function _callee29$(_context29) {
1766
1790
  while (1) {
1767
- switch (_context28.prev = _context28.next) {
1791
+ switch (_context29.prev = _context29.next) {
1768
1792
  case 0:
1769
- _context28.next = 2;
1793
+ _context29.next = 2;
1770
1794
  return this.refreshTokenIfNeeded();
1771
1795
 
1772
1796
  case 2:
1773
1797
  _comoData24 = this.comoData, token = _comoData24.token, installationId = _comoData24.installationId, locationId = _comoData24.locationId, env = _comoData24.env_params;
1774
- return _context28.abrupt('return', urlsUtils.appendQuery(env.app_modules_root + '/profile?token=' + token + '&locationid=' + locationId, (0, _extends3.default)({}, this.getCredentials(), {
1798
+ return _context29.abrupt('return', urlsUtils.appendQuery(env.app_modules_root + '/profile?token=' + token + '&locationid=' + locationId, (0, _extends3.default)({}, this.getCredentials(), {
1775
1799
  installationId: installationId,
1776
1800
  disableSuccessScreen: 'true'
1777
1801
  }, overrides)));
1778
1802
 
1779
1803
  case 4:
1780
1804
  case 'end':
1781
- return _context28.stop();
1805
+ return _context29.stop();
1782
1806
  }
1783
1807
  }
1784
- }, _callee28, this);
1808
+ }, _callee29, this);
1785
1809
  }));
1786
1810
 
1787
1811
  function getProfileUrl(_x50) {
1788
- return _ref29.apply(this, arguments);
1812
+ return _ref30.apply(this, arguments);
1789
1813
  }
1790
1814
 
1791
1815
  return getProfileUrl;
@@ -1798,30 +1822,30 @@ var Como = function () {
1798
1822
  }, {
1799
1823
  key: 'getLoginUrl',
1800
1824
  value: function () {
1801
- var _ref30 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee29() {
1825
+ var _ref31 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee30() {
1802
1826
  var _comoData25, token, locationId, env;
1803
1827
 
1804
- return _regenerator2.default.wrap(function _callee29$(_context29) {
1828
+ return _regenerator2.default.wrap(function _callee30$(_context30) {
1805
1829
  while (1) {
1806
- switch (_context29.prev = _context29.next) {
1830
+ switch (_context30.prev = _context30.next) {
1807
1831
  case 0:
1808
- _context29.next = 2;
1832
+ _context30.next = 2;
1809
1833
  return this.refreshTokenIfNeeded();
1810
1834
 
1811
1835
  case 2:
1812
1836
  _comoData25 = this.comoData, token = _comoData25.token, locationId = _comoData25.locationId, env = _comoData25.env_params;
1813
- return _context29.abrupt('return', env.app_modules_root + '/login?token=' + token + '&locationid=' + locationId);
1837
+ return _context30.abrupt('return', env.app_modules_root + '/login?token=' + token + '&locationid=' + locationId);
1814
1838
 
1815
1839
  case 4:
1816
1840
  case 'end':
1817
- return _context29.stop();
1841
+ return _context30.stop();
1818
1842
  }
1819
1843
  }
1820
- }, _callee29, this);
1844
+ }, _callee30, this);
1821
1845
  }));
1822
1846
 
1823
1847
  function getLoginUrl() {
1824
- return _ref30.apply(this, arguments);
1848
+ return _ref31.apply(this, arguments);
1825
1849
  }
1826
1850
 
1827
1851
  return getLoginUrl;
@@ -1834,31 +1858,31 @@ var Como = function () {
1834
1858
  }, {
1835
1859
  key: 'getDataPortabilityUrl',
1836
1860
  value: function () {
1837
- var _ref31 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee30(url, overrides) {
1861
+ var _ref32 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee31(url, overrides) {
1838
1862
  var installationId;
1839
- return _regenerator2.default.wrap(function _callee30$(_context30) {
1863
+ return _regenerator2.default.wrap(function _callee31$(_context31) {
1840
1864
  while (1) {
1841
- switch (_context30.prev = _context30.next) {
1865
+ switch (_context31.prev = _context31.next) {
1842
1866
  case 0:
1843
- _context30.next = 2;
1867
+ _context31.next = 2;
1844
1868
  return this.refreshTokenIfNeeded();
1845
1869
 
1846
1870
  case 2:
1847
1871
  installationId = this.comoData.installationId;
1848
- return _context30.abrupt('return', urlsUtils.appendQuery('' + url, (0, _extends3.default)({
1872
+ return _context31.abrupt('return', urlsUtils.appendQuery('' + url, (0, _extends3.default)({
1849
1873
  installationId: installationId
1850
1874
  }, overrides)));
1851
1875
 
1852
1876
  case 4:
1853
1877
  case 'end':
1854
- return _context30.stop();
1878
+ return _context31.stop();
1855
1879
  }
1856
1880
  }
1857
- }, _callee30, this);
1881
+ }, _callee31, this);
1858
1882
  }));
1859
1883
 
1860
1884
  function getDataPortabilityUrl(_x51, _x52) {
1861
- return _ref31.apply(this, arguments);
1885
+ return _ref32.apply(this, arguments);
1862
1886
  }
1863
1887
 
1864
1888
  return getDataPortabilityUrl;
@@ -1871,29 +1895,29 @@ var Como = function () {
1871
1895
  }, {
1872
1896
  key: 'getAppModulesLegacyBaseUrl',
1873
1897
  value: function () {
1874
- var _ref32 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee31() {
1898
+ var _ref33 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee32() {
1875
1899
  var env;
1876
- return _regenerator2.default.wrap(function _callee31$(_context31) {
1900
+ return _regenerator2.default.wrap(function _callee32$(_context32) {
1877
1901
  while (1) {
1878
- switch (_context31.prev = _context31.next) {
1902
+ switch (_context32.prev = _context32.next) {
1879
1903
  case 0:
1880
- _context31.next = 2;
1904
+ _context32.next = 2;
1881
1905
  return this.refreshTokenIfNeeded();
1882
1906
 
1883
1907
  case 2:
1884
1908
  env = this.comoData.env_params;
1885
- return _context31.abrupt('return', '' + env.app_modules_legacy_root);
1909
+ return _context32.abrupt('return', '' + env.app_modules_legacy_root);
1886
1910
 
1887
1911
  case 4:
1888
1912
  case 'end':
1889
- return _context31.stop();
1913
+ return _context32.stop();
1890
1914
  }
1891
1915
  }
1892
- }, _callee31, this);
1916
+ }, _callee32, this);
1893
1917
  }));
1894
1918
 
1895
1919
  function getAppModulesLegacyBaseUrl() {
1896
- return _ref32.apply(this, arguments);
1920
+ return _ref33.apply(this, arguments);
1897
1921
  }
1898
1922
 
1899
1923
  return getAppModulesLegacyBaseUrl;
@@ -1990,26 +2014,26 @@ var Como = function () {
1990
2014
  }, {
1991
2015
  key: 'getRegionConfig',
1992
2016
  value: function () {
1993
- var _ref33 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee32() {
2017
+ var _ref34 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee33() {
1994
2018
  var _comoData28, api, locationId, env;
1995
2019
 
1996
- return _regenerator2.default.wrap(function _callee32$(_context32) {
2020
+ return _regenerator2.default.wrap(function _callee33$(_context33) {
1997
2021
  while (1) {
1998
- switch (_context32.prev = _context32.next) {
2022
+ switch (_context33.prev = _context33.next) {
1999
2023
  case 0:
2000
2024
  _comoData28 = this.comoData, api = _comoData28.api, locationId = _comoData28.locationId, env = _comoData28.env_params;
2001
- return _context32.abrupt('return', api.getClientBusinessBackend(env.zapp_root, locationId));
2025
+ return _context33.abrupt('return', api.getClientBusinessBackend(env.zapp_root, locationId));
2002
2026
 
2003
2027
  case 2:
2004
2028
  case 'end':
2005
- return _context32.stop();
2029
+ return _context33.stop();
2006
2030
  }
2007
2031
  }
2008
- }, _callee32, this);
2032
+ }, _callee33, this);
2009
2033
  }));
2010
2034
 
2011
2035
  function getRegionConfig() {
2012
- return _ref33.apply(this, arguments);
2036
+ return _ref34.apply(this, arguments);
2013
2037
  }
2014
2038
 
2015
2039
  return getRegionConfig;
@@ -2032,26 +2056,26 @@ var Como = function () {
2032
2056
  }, {
2033
2057
  key: 'addPaymentMethod',
2034
2058
  value: function () {
2035
- var _ref34 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee33(cardToken) {
2059
+ var _ref35 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee34(cardToken) {
2036
2060
  var _comoData30, api, locationId, token, env;
2037
2061
 
2038
- return _regenerator2.default.wrap(function _callee33$(_context33) {
2062
+ return _regenerator2.default.wrap(function _callee34$(_context34) {
2039
2063
  while (1) {
2040
- switch (_context33.prev = _context33.next) {
2064
+ switch (_context34.prev = _context34.next) {
2041
2065
  case 0:
2042
2066
  _comoData30 = this.comoData, api = _comoData30.api, locationId = _comoData30.locationId, token = _comoData30.token, env = _comoData30.env_params;
2043
- return _context33.abrupt('return', api.addPaymentMethod(env.services_root, locationId, token, cardToken));
2067
+ return _context34.abrupt('return', api.addPaymentMethod(env.services_root, locationId, token, cardToken));
2044
2068
 
2045
2069
  case 2:
2046
2070
  case 'end':
2047
- return _context33.stop();
2071
+ return _context34.stop();
2048
2072
  }
2049
2073
  }
2050
- }, _callee33, this);
2074
+ }, _callee34, this);
2051
2075
  }));
2052
2076
 
2053
2077
  function addPaymentMethod(_x54) {
2054
- return _ref34.apply(this, arguments);
2078
+ return _ref35.apply(this, arguments);
2055
2079
  }
2056
2080
 
2057
2081
  return addPaymentMethod;
@@ -2059,26 +2083,26 @@ var Como = function () {
2059
2083
  }, {
2060
2084
  key: 'knowYourData',
2061
2085
  value: function () {
2062
- var _ref35 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee34(email) {
2086
+ var _ref36 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee35(email) {
2063
2087
  var _comoData31, api, locationId, env;
2064
2088
 
2065
- return _regenerator2.default.wrap(function _callee34$(_context34) {
2089
+ return _regenerator2.default.wrap(function _callee35$(_context35) {
2066
2090
  while (1) {
2067
- switch (_context34.prev = _context34.next) {
2091
+ switch (_context35.prev = _context35.next) {
2068
2092
  case 0:
2069
2093
  _comoData31 = this.comoData, api = _comoData31.api, locationId = _comoData31.locationId, env = _comoData31.env_params;
2070
- return _context34.abrupt('return', api.knowYourData(env.services_root, locationId, email));
2094
+ return _context35.abrupt('return', api.knowYourData(env.services_root, locationId, email));
2071
2095
 
2072
2096
  case 2:
2073
2097
  case 'end':
2074
- return _context34.stop();
2098
+ return _context35.stop();
2075
2099
  }
2076
2100
  }
2077
- }, _callee34, this);
2101
+ }, _callee35, this);
2078
2102
  }));
2079
2103
 
2080
2104
  function knowYourData(_x55) {
2081
- return _ref35.apply(this, arguments);
2105
+ return _ref36.apply(this, arguments);
2082
2106
  }
2083
2107
 
2084
2108
  return knowYourData;
@@ -2086,26 +2110,26 @@ var Como = function () {
2086
2110
  }, {
2087
2111
  key: 'consentWithdraw',
2088
2112
  value: function () {
2089
- var _ref36 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee35(consentData) {
2113
+ var _ref37 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee36(consentData) {
2090
2114
  var _comoData32, api, locationId, env;
2091
2115
 
2092
- return _regenerator2.default.wrap(function _callee35$(_context35) {
2116
+ return _regenerator2.default.wrap(function _callee36$(_context36) {
2093
2117
  while (1) {
2094
- switch (_context35.prev = _context35.next) {
2118
+ switch (_context36.prev = _context36.next) {
2095
2119
  case 0:
2096
2120
  _comoData32 = this.comoData, api = _comoData32.api, locationId = _comoData32.locationId, env = _comoData32.env_params;
2097
- return _context35.abrupt('return', api.consentWithdraw(env.services_root, locationId, consentData));
2121
+ return _context36.abrupt('return', api.consentWithdraw(env.services_root, locationId, consentData));
2098
2122
 
2099
2123
  case 2:
2100
2124
  case 'end':
2101
- return _context35.stop();
2125
+ return _context36.stop();
2102
2126
  }
2103
2127
  }
2104
- }, _callee35, this);
2128
+ }, _callee36, this);
2105
2129
  }));
2106
2130
 
2107
2131
  function consentWithdraw(_x56) {
2108
- return _ref36.apply(this, arguments);
2132
+ return _ref37.apply(this, arguments);
2109
2133
  }
2110
2134
 
2111
2135
  return consentWithdraw;
@@ -2113,31 +2137,31 @@ var Como = function () {
2113
2137
  }, {
2114
2138
  key: 'getPaymentMethods',
2115
2139
  value: function () {
2116
- var _ref37 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee36() {
2140
+ var _ref38 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee37() {
2117
2141
  var _comoData33, env, locationId, api, responseJson;
2118
2142
 
2119
- return _regenerator2.default.wrap(function _callee36$(_context36) {
2143
+ return _regenerator2.default.wrap(function _callee37$(_context37) {
2120
2144
  while (1) {
2121
- switch (_context36.prev = _context36.next) {
2145
+ switch (_context37.prev = _context37.next) {
2122
2146
  case 0:
2123
2147
  _comoData33 = this.comoData, env = _comoData33.env_params, locationId = _comoData33.locationId, api = _comoData33.api;
2124
- _context36.next = 3;
2148
+ _context37.next = 3;
2125
2149
  return api.getPaymentMethods(env.services_root, locationId);
2126
2150
 
2127
2151
  case 3:
2128
- responseJson = _context36.sent;
2129
- return _context36.abrupt('return', responseJson);
2152
+ responseJson = _context37.sent;
2153
+ return _context37.abrupt('return', responseJson);
2130
2154
 
2131
2155
  case 5:
2132
2156
  case 'end':
2133
- return _context36.stop();
2157
+ return _context37.stop();
2134
2158
  }
2135
2159
  }
2136
- }, _callee36, this);
2160
+ }, _callee37, this);
2137
2161
  }));
2138
2162
 
2139
2163
  function getPaymentMethods() {
2140
- return _ref37.apply(this, arguments);
2164
+ return _ref38.apply(this, arguments);
2141
2165
  }
2142
2166
 
2143
2167
  return getPaymentMethods;
@@ -2154,31 +2178,31 @@ var Como = function () {
2154
2178
  }, {
2155
2179
  key: 'payInApp',
2156
2180
  value: function () {
2157
- var _ref38 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee37(amount, creditCardToken, itemName, itemNumber, membershipKey) {
2181
+ var _ref39 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee38(amount, creditCardToken, itemName, itemNumber, membershipKey) {
2158
2182
  var _comoData34, env, token, locationId, api, responseJson;
2159
2183
 
2160
- return _regenerator2.default.wrap(function _callee37$(_context37) {
2184
+ return _regenerator2.default.wrap(function _callee38$(_context38) {
2161
2185
  while (1) {
2162
- switch (_context37.prev = _context37.next) {
2186
+ switch (_context38.prev = _context38.next) {
2163
2187
  case 0:
2164
2188
  _comoData34 = this.comoData, env = _comoData34.env_params, token = _comoData34.token, locationId = _comoData34.locationId, api = _comoData34.api;
2165
- _context37.next = 3;
2189
+ _context38.next = 3;
2166
2190
  return api.payInApp(env.services_root, locationId, token, amount, creditCardToken, itemName, itemNumber, membershipKey);
2167
2191
 
2168
2192
  case 3:
2169
- responseJson = _context37.sent;
2170
- return _context37.abrupt('return', responseJson);
2193
+ responseJson = _context38.sent;
2194
+ return _context38.abrupt('return', responseJson);
2171
2195
 
2172
2196
  case 5:
2173
2197
  case 'end':
2174
- return _context37.stop();
2198
+ return _context38.stop();
2175
2199
  }
2176
2200
  }
2177
- }, _callee37, this);
2201
+ }, _callee38, this);
2178
2202
  }));
2179
2203
 
2180
2204
  function payInApp(_x57, _x58, _x59, _x60, _x61) {
2181
- return _ref38.apply(this, arguments);
2205
+ return _ref39.apply(this, arguments);
2182
2206
  }
2183
2207
 
2184
2208
  return payInApp;
@@ -2191,31 +2215,31 @@ var Como = function () {
2191
2215
  }, {
2192
2216
  key: 'deletePayment',
2193
2217
  value: function () {
2194
- var _ref39 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee38(creditCardToken) {
2218
+ var _ref40 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee39(creditCardToken) {
2195
2219
  var _comoData35, env, token, locationId, api, responseJson;
2196
2220
 
2197
- return _regenerator2.default.wrap(function _callee38$(_context38) {
2221
+ return _regenerator2.default.wrap(function _callee39$(_context39) {
2198
2222
  while (1) {
2199
- switch (_context38.prev = _context38.next) {
2223
+ switch (_context39.prev = _context39.next) {
2200
2224
  case 0:
2201
2225
  _comoData35 = this.comoData, env = _comoData35.env_params, token = _comoData35.token, locationId = _comoData35.locationId, api = _comoData35.api;
2202
- _context38.next = 3;
2226
+ _context39.next = 3;
2203
2227
  return api.deletePayment(env.services_root, locationId, token, creditCardToken);
2204
2228
 
2205
2229
  case 3:
2206
- responseJson = _context38.sent;
2207
- return _context38.abrupt('return', responseJson);
2230
+ responseJson = _context39.sent;
2231
+ return _context39.abrupt('return', responseJson);
2208
2232
 
2209
2233
  case 5:
2210
2234
  case 'end':
2211
- return _context38.stop();
2235
+ return _context39.stop();
2212
2236
  }
2213
2237
  }
2214
- }, _callee38, this);
2238
+ }, _callee39, this);
2215
2239
  }));
2216
2240
 
2217
2241
  function deletePayment(_x62) {
2218
- return _ref39.apply(this, arguments);
2242
+ return _ref40.apply(this, arguments);
2219
2243
  }
2220
2244
 
2221
2245
  return deletePayment;
@@ -2227,32 +2251,32 @@ var Como = function () {
2227
2251
  }, {
2228
2252
  key: 'getMemberMessages',
2229
2253
  value: function () {
2230
- var _ref40 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee39(tag, limit, offset) {
2254
+ var _ref41 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee40(tag, limit, offset) {
2231
2255
  var fetchExpiredMessages = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2232
2256
 
2233
2257
  var _comoData36, api, locationId, env;
2234
2258
 
2235
- return _regenerator2.default.wrap(function _callee39$(_context39) {
2259
+ return _regenerator2.default.wrap(function _callee40$(_context40) {
2236
2260
  while (1) {
2237
- switch (_context39.prev = _context39.next) {
2261
+ switch (_context40.prev = _context40.next) {
2238
2262
  case 0:
2239
2263
  _comoData36 = this.comoData, api = _comoData36.api, locationId = _comoData36.locationId, env = _comoData36.env_params;
2240
- _context39.next = 3;
2264
+ _context40.next = 3;
2241
2265
  return this.refreshTokenIfNeeded();
2242
2266
 
2243
2267
  case 3:
2244
- return _context39.abrupt('return', api.getMemberMessages(env.services_root, locationId, tag, limit, offset, fetchExpiredMessages));
2268
+ return _context40.abrupt('return', api.getMemberMessages(env.services_root, locationId, tag, limit, offset, fetchExpiredMessages));
2245
2269
 
2246
2270
  case 4:
2247
2271
  case 'end':
2248
- return _context39.stop();
2272
+ return _context40.stop();
2249
2273
  }
2250
2274
  }
2251
- }, _callee39, this);
2275
+ }, _callee40, this);
2252
2276
  }));
2253
2277
 
2254
2278
  function getMemberMessages(_x63, _x64, _x65) {
2255
- return _ref40.apply(this, arguments);
2279
+ return _ref41.apply(this, arguments);
2256
2280
  }
2257
2281
 
2258
2282
  return getMemberMessages;
@@ -2283,26 +2307,26 @@ var Como = function () {
2283
2307
  }, {
2284
2308
  key: 'budgetTransfer',
2285
2309
  value: function () {
2286
- var _ref41 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee40(receiver, sender, amount, wallet) {
2310
+ var _ref42 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee41(receiver, sender, amount, wallet) {
2287
2311
  var _comoData38, api, locationId, env;
2288
2312
 
2289
- return _regenerator2.default.wrap(function _callee40$(_context40) {
2313
+ return _regenerator2.default.wrap(function _callee41$(_context41) {
2290
2314
  while (1) {
2291
- switch (_context40.prev = _context40.next) {
2315
+ switch (_context41.prev = _context41.next) {
2292
2316
  case 0:
2293
2317
  _comoData38 = this.comoData, api = _comoData38.api, locationId = _comoData38.locationId, env = _comoData38.env_params;
2294
- return _context40.abrupt('return', api.budgetTransfer(env.services_root, locationId, receiver, sender, amount, wallet));
2318
+ return _context41.abrupt('return', api.budgetTransfer(env.services_root, locationId, receiver, sender, amount, wallet));
2295
2319
 
2296
2320
  case 2:
2297
2321
  case 'end':
2298
- return _context40.stop();
2322
+ return _context41.stop();
2299
2323
  }
2300
2324
  }
2301
- }, _callee40, this);
2325
+ }, _callee41, this);
2302
2326
  }));
2303
2327
 
2304
2328
  function budgetTransfer(_x67, _x68, _x69, _x70) {
2305
- return _ref41.apply(this, arguments);
2329
+ return _ref42.apply(this, arguments);
2306
2330
  }
2307
2331
 
2308
2332
  return budgetTransfer;
@@ -2329,26 +2353,26 @@ var Como = function () {
2329
2353
  }, {
2330
2354
  key: 'budgetTransferClaim',
2331
2355
  value: function () {
2332
- var _ref42 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee41(claimCode) {
2356
+ var _ref43 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee42(claimCode) {
2333
2357
  var _comoData40, api, locationId, env;
2334
2358
 
2335
- return _regenerator2.default.wrap(function _callee41$(_context41) {
2359
+ return _regenerator2.default.wrap(function _callee42$(_context42) {
2336
2360
  while (1) {
2337
- switch (_context41.prev = _context41.next) {
2361
+ switch (_context42.prev = _context42.next) {
2338
2362
  case 0:
2339
2363
  _comoData40 = this.comoData, api = _comoData40.api, locationId = _comoData40.locationId, env = _comoData40.env_params;
2340
- return _context41.abrupt('return', api.budgetTransferClaim(env.services_root, locationId, claimCode));
2364
+ return _context42.abrupt('return', api.budgetTransferClaim(env.services_root, locationId, claimCode));
2341
2365
 
2342
2366
  case 2:
2343
2367
  case 'end':
2344
- return _context41.stop();
2368
+ return _context42.stop();
2345
2369
  }
2346
2370
  }
2347
- }, _callee41, this);
2371
+ }, _callee42, this);
2348
2372
  }));
2349
2373
 
2350
2374
  function budgetTransferClaim(_x71) {
2351
- return _ref42.apply(this, arguments);
2375
+ return _ref43.apply(this, arguments);
2352
2376
  }
2353
2377
 
2354
2378
  return budgetTransferClaim;
@@ -2381,26 +2405,26 @@ var Como = function () {
2381
2405
  }, {
2382
2406
  key: 'logUserAction',
2383
2407
  value: function () {
2384
- var _ref43 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee42(action, logData) {
2408
+ var _ref44 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee43(action, logData) {
2385
2409
  var _comoData42, env, locationId, api;
2386
2410
 
2387
- return _regenerator2.default.wrap(function _callee42$(_context42) {
2411
+ return _regenerator2.default.wrap(function _callee43$(_context43) {
2388
2412
  while (1) {
2389
- switch (_context42.prev = _context42.next) {
2413
+ switch (_context43.prev = _context43.next) {
2390
2414
  case 0:
2391
2415
  _comoData42 = this.comoData, env = _comoData42.env_params, locationId = _comoData42.locationId, api = _comoData42.api;
2392
- return _context42.abrupt('return', api.logUserAction(env.zapp_root, locationId, action, logData));
2416
+ return _context43.abrupt('return', api.logUserAction(env.zapp_root, locationId, action, logData));
2393
2417
 
2394
2418
  case 2:
2395
2419
  case 'end':
2396
- return _context42.stop();
2420
+ return _context43.stop();
2397
2421
  }
2398
2422
  }
2399
- }, _callee42, this);
2423
+ }, _callee43, this);
2400
2424
  }));
2401
2425
 
2402
2426
  function logUserAction(_x72, _x73) {
2403
- return _ref43.apply(this, arguments);
2427
+ return _ref44.apply(this, arguments);
2404
2428
  }
2405
2429
 
2406
2430
  return logUserAction;
@@ -2415,26 +2439,26 @@ var Como = function () {
2415
2439
  }, {
2416
2440
  key: 'getPurchaseHistory',
2417
2441
  value: function () {
2418
- var _ref44 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee43(limit, offset) {
2442
+ var _ref45 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee44(limit, offset) {
2419
2443
  var _comoData43, locationId, api, membership;
2420
2444
 
2421
- return _regenerator2.default.wrap(function _callee43$(_context43) {
2445
+ return _regenerator2.default.wrap(function _callee44$(_context44) {
2422
2446
  while (1) {
2423
- switch (_context43.prev = _context43.next) {
2447
+ switch (_context44.prev = _context44.next) {
2424
2448
  case 0:
2425
2449
  _comoData43 = this.comoData, locationId = _comoData43.locationId, api = _comoData43.api, membership = _comoData43.membership;
2426
- return _context43.abrupt('return', api.getPurchaseHistory(locationId, membership.Key, limit, offset));
2450
+ return _context44.abrupt('return', api.getPurchaseHistory(locationId, membership.Key, limit, offset));
2427
2451
 
2428
2452
  case 2:
2429
2453
  case 'end':
2430
- return _context43.stop();
2454
+ return _context44.stop();
2431
2455
  }
2432
2456
  }
2433
- }, _callee43, this);
2457
+ }, _callee44, this);
2434
2458
  }));
2435
2459
 
2436
2460
  function getPurchaseHistory(_x74, _x75) {
2437
- return _ref44.apply(this, arguments);
2461
+ return _ref45.apply(this, arguments);
2438
2462
  }
2439
2463
 
2440
2464
  return getPurchaseHistory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@como/como-client",
3
- "version": "0.7.99",
3
+ "version": "0.8.1",
4
4
  "description": "Client module for Como's loaylty API",
5
5
  "main": "src/como.js",
6
6
  "scripts": {
package/src/como.js CHANGED
@@ -109,6 +109,7 @@ class Como {
109
109
  if(isExpired){
110
110
  try{
111
111
  const data = await this.comoData.initApi.refreshToken(installationId, refreshToken? refreshToken: 'none', locationId, source);
112
+ console.log(`signOn with isExpired true result:${JSON.stringify(data)}`);
112
113
  updateCredentials(data, true);
113
114
  }catch(e){
114
115
  console.error(`Failed to refresh token, installationId:${installationId}, refreshToken:${this.comoData.refreshToken}, locationId:${locationId}, source:${source}`);
@@ -122,6 +123,7 @@ class Como {
122
123
  while(!credExist && interval < 3000){
123
124
  try{
124
125
  const data = await this.comoData.initApi.signOn(installationId, locationId, source);
126
+ console.log(`signOn with refreshFailed result:${JSON.stringify(data)}`);
125
127
  updateCredentials(data, true);
126
128
  credExist = true;
127
129
  }catch(e){
@@ -175,7 +177,7 @@ class Como {
175
177
  this.comoData.token = credentials.accessToken;
176
178
  this.comoData.refreshToken = credentials.refreshToken;
177
179
  this.comoData.expiresIn = credentials.expiresIn;
178
- if(credentials.config){
180
+ if (credentials && credentials.config) {
179
181
  this.comoData.reCaptchaSiteKey = credentials.config.recaptchaSiteKey;
180
182
  if (credentials.config.recaptcha) {
181
183
  this.comoData.recaptchaConfig = credentials.config.recaptcha;
@@ -690,10 +692,10 @@ class Como {
690
692
  */
691
693
  getCredentials() {
692
694
  const {
693
- accessToken, refreshToken, expiresIn, consent, locationId, recaptchaConfig,
695
+ accessToken, refreshToken, expiresIn, consent, locationId,
694
696
  } = this.comoData;
695
697
  return {
696
- accessToken, refreshToken, expiresIn, consent, locationId, recaptchaConfig,
698
+ accessToken, refreshToken, expiresIn, consent, locationId,
697
699
  };
698
700
  }
699
701
 
@@ -723,7 +725,10 @@ class Como {
723
725
  /**
724
726
  * Return service recaptch config
725
727
  */
726
- getRecaptchaConfig() { return { reCaptchaSiteKey: this.comoData.reCaptchaSiteKey, baseUrl: this.comoData.env_params.gateway, recaptchaConfig: this.comoData.recaptchaConfig } }
728
+ async getRecaptchaConfig() {
729
+ await this.refreshTokenIfNeeded();
730
+ return this.comoData.recaptchaConfig;
731
+ }
727
732
 
728
733
  /**
729
734
  * Returns the location specific registration web url