cozy-pouch-link 60.4.0 → 60.5.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.
@@ -649,25 +649,37 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
649
649
  key: "onSyncError",
650
650
  value: function () {
651
651
  var _onSyncError = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(error) {
652
+ var oldToken, newToken;
652
653
  return _regenerator.default.wrap(function _callee5$(_context5) {
653
654
  while (1) {
654
655
  switch (_context5.prev = _context5.next) {
655
656
  case 0:
656
657
  if (!(0, _errors.isExpiredTokenError)(error)) {
657
- _context5.next = 14;
658
+ _context5.next = 18;
658
659
  break;
659
660
  }
660
661
 
661
662
  _context5.prev = 1;
662
- _context5.next = 4;
663
+ oldToken = this.client.stackClient.token;
664
+ _context5.next = 5;
663
665
  return this.client.stackClient.refreshToken();
664
666
 
665
- case 4:
667
+ case 5:
668
+ newToken = this.client.stackClient.token;
669
+
670
+ if (!(newToken === oldToken || !newToken)) {
671
+ _context5.next = 8;
672
+ break;
673
+ }
674
+
675
+ throw new Error('Refresh token failed');
676
+
677
+ case 8:
666
678
  this.startReplication();
667
679
  return _context5.abrupt("return");
668
680
 
669
- case 8:
670
- _context5.prev = 8;
681
+ case 12:
682
+ _context5.prev = 12;
671
683
  _context5.t0 = _context5["catch"](1);
672
684
 
673
685
  _logger.default.warn('Could not refresh token, replication has stopped', _context5.t0);
@@ -676,23 +688,23 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
676
688
  this.options.onSyncError.call(this, _context5.t0);
677
689
  }
678
690
 
679
- case 12:
680
- _context5.next = 16;
691
+ case 16:
692
+ _context5.next = 20;
681
693
  break;
682
694
 
683
- case 14:
695
+ case 18:
684
696
  _logger.default.warn('CozyPouchLink: Synchronization error', error);
685
697
 
686
698
  if (this.options.onSyncError) {
687
699
  this.options.onSyncError.call(this, error);
688
700
  }
689
701
 
690
- case 16:
702
+ case 20:
691
703
  case "end":
692
704
  return _context5.stop();
693
705
  }
694
706
  }
695
- }, _callee5, this, [[1, 8]]);
707
+ }, _callee5, this, [[1, 12]]);
696
708
  }));
697
709
 
698
710
  function onSyncError(_x3) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-pouch-link",
3
- "version": "60.4.0",
3
+ "version": "60.5.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "url": "git+https://github.com/cozy/cozy-client.git"
14
14
  },
15
15
  "dependencies": {
16
- "cozy-client": "^60.3.0",
16
+ "cozy-client": "^60.5.0",
17
17
  "pouchdb-browser": "^7.2.2",
18
18
  "pouchdb-find": "^7.2.2"
19
19
  },
@@ -41,5 +41,5 @@
41
41
  "typecheck": "tsc -p tsconfig.json"
42
42
  },
43
43
  "sideEffects": false,
44
- "gitHead": "13f9b0ce0bb23b21654643c7d365d150043b0aa8"
44
+ "gitHead": "5917d6e962551c1220a9a8288f1bf4a51a5065f6"
45
45
  }