@mcurros2/microm 1.1.143-0 → 1.1.145-0

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/dist/index.js CHANGED
@@ -1446,6 +1446,8 @@ var $brSbF = parcelRequire("brSbF");
1446
1446
 
1447
1447
  var $78KzE = parcelRequire("78KzE");
1448
1448
 
1449
+ var $dF8o7 = parcelRequire("dF8o7");
1450
+
1449
1451
  var $2VTPU = parcelRequire("2VTPU");
1450
1452
  var $a1f6b3ef69eb7cc7$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
1451
1453
  function adopt(value) {
@@ -1533,33 +1535,39 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1533
1535
  logoff() {
1534
1536
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1535
1537
  var _a;
1536
- yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_removeToken).call(this);
1537
- yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_deleteEnabledMenus).call(this);
1538
- if ($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS, "f")) $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_saveAllRecordedAccess).call(this);
1539
- //TODO: explicar por que no envía el token con esta solicitud?
1540
- const response = yield fetch(`${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL, "f")}/${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f")}/logoff`, {
1541
- method: "POST",
1542
- headers: {
1543
- "Content-Type": "application/json; charset=utf-8",
1544
- "Authorization": `Bearer ${((_a = $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f")) === null || _a === void 0 ? void 0 : _a.access_token) || ""}`
1545
- },
1546
- mode: $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_REQUEST_MODE, "f"),
1547
- cache: "no-store",
1548
- credentials: "include",
1549
- referrerPolicy: "strict-origin-when-cross-origin",
1550
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f")),
1551
- body: JSON.stringify({})
1552
- });
1553
- if (!response.ok) throw {
1554
- status: response.status,
1555
- statusMessage: response.statusText,
1556
- message: response.statusText,
1557
- url: response.url
1558
- };
1538
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f"), "Login request timed out");
1539
+ try {
1540
+ yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_removeToken).call(this);
1541
+ yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_deleteEnabledMenus).call(this);
1542
+ if ($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS, "f")) $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_saveAllRecordedAccess).call(this);
1543
+ //TODO: explicar por que no envía el token con esta solicitud?
1544
+ const response = yield fetch(`${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL, "f")}/${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f")}/logoff`, {
1545
+ method: "POST",
1546
+ headers: {
1547
+ "Content-Type": "application/json; charset=utf-8",
1548
+ "Authorization": `Bearer ${((_a = $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f")) === null || _a === void 0 ? void 0 : _a.access_token) || ""}`
1549
+ },
1550
+ mode: $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_REQUEST_MODE, "f"),
1551
+ cache: "no-store",
1552
+ credentials: "include",
1553
+ referrerPolicy: "strict-origin-when-cross-origin",
1554
+ signal: loginTimeout.signal,
1555
+ body: JSON.stringify({})
1556
+ });
1557
+ if (!response.ok) throw {
1558
+ status: response.status,
1559
+ statusMessage: response.statusText,
1560
+ message: response.statusText,
1561
+ url: response.url
1562
+ };
1563
+ } finally{
1564
+ loginTimeout.clear();
1565
+ }
1559
1566
  });
1560
1567
  }
1561
1568
  isLoggedIn() {
1562
1569
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1570
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f"), "Login request timed out");
1563
1571
  try {
1564
1572
  yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_checkAndRefreshToken).call(this);
1565
1573
  if ($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f") !== null && $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f").access_token !== "") {
@@ -1573,12 +1581,14 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1573
1581
  cache: "no-store",
1574
1582
  credentials: "include",
1575
1583
  referrerPolicy: "strict-origin-when-cross-origin",
1576
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f"))
1584
+ signal: loginTimeout.signal
1577
1585
  });
1578
1586
  return response.ok;
1579
1587
  }
1580
1588
  } catch (error) {
1581
1589
  //console.log(error);
1590
+ } finally{
1591
+ loginTimeout.clear();
1582
1592
  }
1583
1593
  return false;
1584
1594
  });
@@ -1609,6 +1619,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1609
1619
  login(username, password, rememberme) {
1610
1620
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1611
1621
  //Intentionally not accounting for tokenRefreshInProgress (see refresh logic)
1622
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f"), "Login request timed out");
1612
1623
  try {
1613
1624
  if ($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS, "f")) $a1f6b3ef69eb7cc7$var$__classPrivateFieldSet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORDED_PATHS, {}, "f");
1614
1625
  const response = yield fetch(`${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL, "f")}/${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f")}/login`, {
@@ -1620,7 +1631,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1620
1631
  cache: "no-store",
1621
1632
  credentials: "include",
1622
1633
  referrerPolicy: "strict-origin-when-cross-origin",
1623
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f")),
1634
+ signal: loginTimeout.signal,
1624
1635
  body: JSON.stringify({
1625
1636
  username: username,
1626
1637
  password: password
@@ -1657,13 +1668,17 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1657
1668
  url: response.url
1658
1669
  };
1659
1670
  } catch (error) {
1671
+ yield this.localLogoff();
1660
1672
  if (!(error instanceof Error && error.name === "AbortError")) //console.log(error);
1661
1673
  throw error;
1674
+ } finally{
1675
+ loginTimeout.clear();
1662
1676
  }
1663
1677
  });
1664
1678
  }
1665
1679
  recoveryemail(username) {
1666
1680
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1681
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f") * 4, "Login request timed out");
1667
1682
  try {
1668
1683
  const response = yield fetch(`${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL, "f")}/${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f")}/recoveryemail`, {
1669
1684
  method: "POST",
@@ -1674,7 +1689,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1674
1689
  cache: "no-store",
1675
1690
  credentials: "include",
1676
1691
  referrerPolicy: "strict-origin-when-cross-origin",
1677
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f") * 4),
1692
+ signal: loginTimeout.signal,
1678
1693
  body: JSON.stringify({
1679
1694
  username: username
1680
1695
  })
@@ -1688,11 +1703,14 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1688
1703
  return yield response.json();
1689
1704
  } catch (error) {
1690
1705
  throw error;
1706
+ } finally{
1707
+ loginTimeout.clear();
1691
1708
  }
1692
1709
  });
1693
1710
  }
1694
1711
  recoverpassword(username, password, recoverycode) {
1695
1712
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1713
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f") * 4, "Login request timed out");
1696
1714
  try {
1697
1715
  const response = yield fetch(`${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL, "f")}/${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f")}/recoverpassword`, {
1698
1716
  method: "POST",
@@ -1703,7 +1721,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1703
1721
  cache: "no-store",
1704
1722
  credentials: "include",
1705
1723
  referrerPolicy: "strict-origin-when-cross-origin",
1706
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f") * 4),
1724
+ signal: loginTimeout.signal,
1707
1725
  body: JSON.stringify({
1708
1726
  username: username,
1709
1727
  password: password,
@@ -1719,6 +1737,8 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1719
1737
  return yield response.json();
1720
1738
  } catch (error) {
1721
1739
  throw error;
1740
+ } finally{
1741
+ loginTimeout.clear();
1722
1742
  }
1723
1743
  });
1724
1744
  }
@@ -2054,6 +2074,7 @@ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$v
2054
2074
  return $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress, "f");
2055
2075
  }
2056
2076
  const _performTokenRefresh = ()=>$a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
2077
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f"), "Login request timed out");
2057
2078
  try {
2058
2079
  if (!$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f")) throw new Error("Token not found");
2059
2080
  //console.log('Refreshing token');
@@ -2067,7 +2088,7 @@ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$v
2067
2088
  cache: "no-store",
2068
2089
  credentials: "include",
2069
2090
  referrerPolicy: "strict-origin-when-cross-origin",
2070
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f")),
2091
+ signal: loginTimeout.signal,
2071
2092
  body: JSON.stringify({
2072
2093
  Bearer: $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f").access_token,
2073
2094
  RefreshToken: $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f").refresh_token
@@ -2096,6 +2117,7 @@ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$v
2096
2117
  throw error;
2097
2118
  } finally{
2098
2119
  $a1f6b3ef69eb7cc7$var$__classPrivateFieldSet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress, null, "f"); // Clear the ongoing refresh promise once done.
2120
+ loginTimeout.clear();
2099
2121
  }
2100
2122
  });
2101
2123
  $a1f6b3ef69eb7cc7$var$__classPrivateFieldSet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress, _performTokenRefresh(), "f");
@@ -2548,6 +2570,33 @@ class $532d68612f64024e$export$63afd07a6b828dcd {
2548
2570
 
2549
2571
  });
2550
2572
 
2573
+ parcelRegister("dF8o7", function(module, exports) {
2574
+
2575
+ $parcel$export(module.exports, "TimeoutSignal", function () { return $9f259c618a3beb21$export$c9297bdae1627606; });
2576
+ class $9f259c618a3beb21$export$c9297bdae1627606 {
2577
+ constructor(timeoutMs, errorMessage = "Request timed out"){
2578
+ this.controller = new AbortController();
2579
+ this.signal = this.controller.signal;
2580
+ this.timeoutId = setTimeout(()=>{
2581
+ this.controller.abort(new DOMException(errorMessage, "TimeoutError"));
2582
+ }, timeoutMs);
2583
+ }
2584
+ clear() {
2585
+ if (this.timeoutId) {
2586
+ clearTimeout(this.timeoutId);
2587
+ this.timeoutId = undefined;
2588
+ }
2589
+ }
2590
+ get aborted() {
2591
+ return this.signal.aborted;
2592
+ }
2593
+ get abortReason() {
2594
+ return this.signal.reason;
2595
+ }
2596
+ }
2597
+
2598
+ });
2599
+
2551
2600
  parcelRegister("2VTPU", function(module, exports) {
2552
2601
 
2553
2602
  $parcel$export(module.exports, "TokenWebStorage", function () { return $222c37917e487551$export$1f670b0f74ee9970; });