@sambath999/localize-token 12.4.5 → 12.4.7

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.
@@ -521,36 +521,51 @@
521
521
  function waitUntil(when, intervalNumber) {
522
522
  if (intervalNumber === void 0) { intervalNumber = 50; }
523
523
  return __awaiter(this, void 0, void 0, function () {
524
+ function isConditionMet() {
525
+ return __awaiter(this, void 0, void 0, function () {
526
+ var cond, result, _a;
527
+ return __generator(this, function (_b) {
528
+ switch (_b.label) {
529
+ case 0:
530
+ cond = when();
531
+ if (!(cond instanceof Promise)) return [3 /*break*/, 2];
532
+ return [4 /*yield*/, cond];
533
+ case 1:
534
+ _a = _b.sent();
535
+ return [3 /*break*/, 3];
536
+ case 2:
537
+ _a = cond;
538
+ _b.label = 3;
539
+ case 3:
540
+ result = _a;
541
+ return [2 /*return*/, result];
542
+ }
543
+ });
544
+ });
545
+ }
524
546
  var _this = this;
525
547
  return __generator(this, function (_a) {
526
548
  switch (_a.label) {
527
- case 0: return [4 /*yield*/, new Promise(function (resolve) {
528
- var interval = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
529
- var cond, result, _a;
530
- return __generator(this, function (_b) {
531
- switch (_b.label) {
532
- case 0:
533
- cond = when();
534
- if (!(cond instanceof Promise)) return [3 /*break*/, 2];
535
- return [4 /*yield*/, cond];
536
- case 1:
537
- _a = _b.sent();
538
- return [3 /*break*/, 3];
539
- case 2:
540
- _a = cond;
541
- _b.label = 3;
542
- case 3:
543
- result = _a;
544
- if (result) {
545
- clearInterval(interval);
546
- resolve(true);
547
- }
548
- return [2 /*return*/];
549
- }
550
- });
551
- }); }, intervalNumber);
552
- })];
549
+ case 0: return [4 /*yield*/, isConditionMet()];
553
550
  case 1:
551
+ if (_a.sent())
552
+ return [2 /*return*/];
553
+ return [4 /*yield*/, new Promise(function (resolve) {
554
+ var interval = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
555
+ return __generator(this, function (_a) {
556
+ switch (_a.label) {
557
+ case 0: return [4 /*yield*/, isConditionMet()];
558
+ case 1:
559
+ if (_a.sent()) {
560
+ clearInterval(interval);
561
+ resolve(true);
562
+ }
563
+ return [2 /*return*/];
564
+ }
565
+ });
566
+ }); }, intervalNumber);
567
+ })];
568
+ case 2:
554
569
  _a.sent();
555
570
  return [2 /*return*/];
556
571
  }
@@ -653,8 +668,11 @@
653
668
  };
654
669
  LocalizeTokenService.prototype.tokensValid = function () {
655
670
  var _a, _b;
656
- return !!((_a = this.refreshToken) === null || _a === void 0 ? void 0 : _a.length)
657
- && (!this.config.tenantToken || !!((_b = this.tenantToken) === null || _b === void 0 ? void 0 : _b.length));
671
+ if (!((_a = this.refreshToken) === null || _a === void 0 ? void 0 : _a.length))
672
+ return false;
673
+ if (this.config.requiredTenant && !((_b = this.tenantToken) === null || _b === void 0 ? void 0 : _b.length))
674
+ return false;
675
+ return true;
658
676
  };
659
677
  Object.defineProperty(LocalizeTokenService.prototype, "decodeRefreshToken", {
660
678
  get: function () {
@@ -1349,7 +1367,7 @@
1349
1367
  case 5:
1350
1368
  // Handle the error, log it
1351
1369
  _e.sent();
1352
- return [3 /*break*/, 7];
1370
+ throw error_2;
1353
1371
  case 6:
1354
1372
  // Reset the revoking token state
1355
1373
  this.isRevokingToken = false;
@@ -1382,10 +1400,8 @@
1382
1400
  switch (_e.label) {
1383
1401
  case 0:
1384
1402
  if (!this.isRevokingToken) return [3 /*break*/, 2];
1385
- // console.warn('A token refresh is in progress. Request is waiting.');
1386
1403
  return [4 /*yield*/, waitUntil(function () { return !_this.isRevokingToken; })];
1387
1404
  case 1:
1388
- // console.warn('A token refresh is in progress. Request is waiting.');
1389
1405
  _e.sent();
1390
1406
  _e.label = 2;
1391
1407
  case 2:
@@ -1447,7 +1463,7 @@
1447
1463
  };
1448
1464
  LocalizeApiService.prototype.validateConfig = function () {
1449
1465
  var _a, _b, _c, _d;
1450
- if (this.localizeTokenService.config.tenantToken
1466
+ if (this.localizeTokenService.config.requiredTenant
1451
1467
  && !((_b = (_a = this.localizeTokenService.config.tenantToken) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.trim().length)) {
1452
1468
  throw Error('Tenant token is required but tenantTokenName is not configured');
1453
1469
  }