@mcurros2/microm 1.1.142-0 → 1.1.144-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
@@ -1659,11 +1670,14 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1659
1670
  } catch (error) {
1660
1671
  if (!(error instanceof Error && error.name === "AbortError")) //console.log(error);
1661
1672
  throw error;
1673
+ } finally{
1674
+ loginTimeout.clear();
1662
1675
  }
1663
1676
  });
1664
1677
  }
1665
1678
  recoveryemail(username) {
1666
1679
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1680
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f") * 4, "Login request timed out");
1667
1681
  try {
1668
1682
  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
1683
  method: "POST",
@@ -1674,7 +1688,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1674
1688
  cache: "no-store",
1675
1689
  credentials: "include",
1676
1690
  referrerPolicy: "strict-origin-when-cross-origin",
1677
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f") * 4),
1691
+ signal: loginTimeout.signal,
1678
1692
  body: JSON.stringify({
1679
1693
  username: username
1680
1694
  })
@@ -1688,11 +1702,14 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1688
1702
  return yield response.json();
1689
1703
  } catch (error) {
1690
1704
  throw error;
1705
+ } finally{
1706
+ loginTimeout.clear();
1691
1707
  }
1692
1708
  });
1693
1709
  }
1694
1710
  recoverpassword(username, password, recoverycode) {
1695
1711
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1712
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f") * 4, "Login request timed out");
1696
1713
  try {
1697
1714
  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
1715
  method: "POST",
@@ -1703,7 +1720,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1703
1720
  cache: "no-store",
1704
1721
  credentials: "include",
1705
1722
  referrerPolicy: "strict-origin-when-cross-origin",
1706
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f") * 4),
1723
+ signal: loginTimeout.signal,
1707
1724
  body: JSON.stringify({
1708
1725
  username: username,
1709
1726
  password: password,
@@ -1719,6 +1736,8 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1719
1736
  return yield response.json();
1720
1737
  } catch (error) {
1721
1738
  throw error;
1739
+ } finally{
1740
+ loginTimeout.clear();
1722
1741
  }
1723
1742
  });
1724
1743
  }
@@ -1961,11 +1980,12 @@ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$v
1961
1980
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, arguments, void 0, function*(abort_signal = null) {
1962
1981
  if (!$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f")) return;
1963
1982
  const result = yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_submitToAPI).call(this, "SystemProcs", null, {}, [], "proc", abort_signal, "sys_GetTimeZoneOffset");
1964
- if (isNaN(result)) {
1983
+ const offset = result[0].records[0][0];
1984
+ if (isNaN(offset)) {
1965
1985
  console.warn("No timezone offset found, using default 0");
1966
1986
  return 0;
1967
1987
  }
1968
- yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_saveTimeZoneOffset).call(this, result);
1988
+ yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_saveTimeZoneOffset).call(this, offset);
1969
1989
  return result;
1970
1990
  });
1971
1991
  }, $a1f6b3ef69eb7cc7$var$_MicroMClient_getAPIEnabledMenus = function _MicroMClient_getAPIEnabledMenus(username_1) {
@@ -2053,6 +2073,7 @@ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$v
2053
2073
  return $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress, "f");
2054
2074
  }
2055
2075
  const _performTokenRefresh = ()=>$a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
2076
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f"), "Login request timed out");
2056
2077
  try {
2057
2078
  if (!$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f")) throw new Error("Token not found");
2058
2079
  //console.log('Refreshing token');
@@ -2066,7 +2087,7 @@ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$v
2066
2087
  cache: "no-store",
2067
2088
  credentials: "include",
2068
2089
  referrerPolicy: "strict-origin-when-cross-origin",
2069
- signal: AbortSignal.timeout($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f")),
2090
+ signal: loginTimeout.signal,
2070
2091
  body: JSON.stringify({
2071
2092
  Bearer: $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f").access_token,
2072
2093
  RefreshToken: $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, "f").refresh_token
@@ -2095,6 +2116,7 @@ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$v
2095
2116
  throw error;
2096
2117
  } finally{
2097
2118
  $a1f6b3ef69eb7cc7$var$__classPrivateFieldSet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress, null, "f"); // Clear the ongoing refresh promise once done.
2119
+ loginTimeout.clear();
2098
2120
  }
2099
2121
  });
2100
2122
  $a1f6b3ef69eb7cc7$var$__classPrivateFieldSet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress, _performTokenRefresh(), "f");
@@ -2547,6 +2569,33 @@ class $532d68612f64024e$export$63afd07a6b828dcd {
2547
2569
 
2548
2570
  });
2549
2571
 
2572
+ parcelRegister("dF8o7", function(module, exports) {
2573
+
2574
+ $parcel$export(module.exports, "TimeoutSignal", function () { return $9f259c618a3beb21$export$c9297bdae1627606; });
2575
+ class $9f259c618a3beb21$export$c9297bdae1627606 {
2576
+ constructor(timeoutMs, errorMessage = "Request timed out"){
2577
+ this.controller = new AbortController();
2578
+ this.signal = this.controller.signal;
2579
+ this.timeoutId = setTimeout(()=>{
2580
+ this.controller.abort(new DOMException(errorMessage, "TimeoutError"));
2581
+ }, timeoutMs);
2582
+ }
2583
+ clear() {
2584
+ if (this.timeoutId) {
2585
+ clearTimeout(this.timeoutId);
2586
+ this.timeoutId = undefined;
2587
+ }
2588
+ }
2589
+ get aborted() {
2590
+ return this.signal.aborted;
2591
+ }
2592
+ get abortReason() {
2593
+ return this.signal.reason;
2594
+ }
2595
+ }
2596
+
2597
+ });
2598
+
2550
2599
  parcelRegister("2VTPU", function(module, exports) {
2551
2600
 
2552
2601
  $parcel$export(module.exports, "TokenWebStorage", function () { return $222c37917e487551$export$1f670b0f74ee9970; });