@mcurros2/microm 1.1.146-0 → 1.1.148-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
@@ -1487,10 +1487,11 @@ var $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet = undefined && undefined.__clas
1487
1487
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1488
1488
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1489
1489
  };
1490
- var $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN_STORAGE, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, $a1f6b3ef69eb7cc7$var$_MicroMClient_REQUEST_MODE, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress, $a1f6b3ef69eb7cc7$var$_MicroMClient_publicEndpoints, $a1f6b3ef69eb7cc7$var$_MicroMClient_DATA_STORAGE, $a1f6b3ef69eb7cc7$var$_MicroMClient_ENABLED_MENUS, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORDED_PATHS, $a1f6b3ef69eb7cc7$var$_MicroMClient_REDIRECT_ON_401, $a1f6b3ef69eb7cc7$var$_MicroMClient_TIMEZONE_OFFSET, $a1f6b3ef69eb7cc7$var$_MicroMClient_recordAccess, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveAllRecordedAccess, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveTimeZoneOffset, $a1f6b3ef69eb7cc7$var$_MicroMClient_readTimeZoneOffset, $a1f6b3ef69eb7cc7$var$_MicroMClient_getTimeZoneOffset, $a1f6b3ef69eb7cc7$var$_MicroMClient_getAPIEnabledMenus, $a1f6b3ef69eb7cc7$var$_MicroMClient_uploadFile, $a1f6b3ef69eb7cc7$var$_MicroMClient_refreshToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveRecordedAccessData, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveEnabledMenus, $a1f6b3ef69eb7cc7$var$_MicroMClient_readEnabledMenus, $a1f6b3ef69eb7cc7$var$_MicroMClient_deleteEnabledMenus, $a1f6b3ef69eb7cc7$var$_MicroMClient_loadToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_setToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_removeToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_checkAndRefreshToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_submitToAPI, $a1f6b3ef69eb7cc7$var$_MicroMClient_submitToPublicAPI, $a1f6b3ef69eb7cc7$var$_MicroMClient_isPublicAPI;
1490
+ var $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN_STORAGE, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, $a1f6b3ef69eb7cc7$var$_MicroMClient_REQUEST_MODE, $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOCAL_DEVICE_ID, $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress, $a1f6b3ef69eb7cc7$var$_MicroMClient_publicEndpoints, $a1f6b3ef69eb7cc7$var$_MicroMClient_DATA_STORAGE, $a1f6b3ef69eb7cc7$var$_MicroMClient_ENABLED_MENUS, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORDED_PATHS, $a1f6b3ef69eb7cc7$var$_MicroMClient_REDIRECT_ON_401, $a1f6b3ef69eb7cc7$var$_MicroMClient_TIMEZONE_OFFSET, $a1f6b3ef69eb7cc7$var$_MicroMClient_recordAccess, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveAllRecordedAccess, $a1f6b3ef69eb7cc7$var$_MicroMClient_getLocalDeviceId, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveTimeZoneOffset, $a1f6b3ef69eb7cc7$var$_MicroMClient_readTimeZoneOffset, $a1f6b3ef69eb7cc7$var$_MicroMClient_getTimeZoneOffset, $a1f6b3ef69eb7cc7$var$_MicroMClient_getAPIEnabledMenus, $a1f6b3ef69eb7cc7$var$_MicroMClient_uploadFile, $a1f6b3ef69eb7cc7$var$_MicroMClient_refreshToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveRecordedAccessData, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveEnabledMenus, $a1f6b3ef69eb7cc7$var$_MicroMClient_readEnabledMenus, $a1f6b3ef69eb7cc7$var$_MicroMClient_deleteEnabledMenus, $a1f6b3ef69eb7cc7$var$_MicroMClient_loadToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_setToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_removeToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_checkAndRefreshToken, $a1f6b3ef69eb7cc7$var$_MicroMClient_submitToAPI, $a1f6b3ef69eb7cc7$var$_MicroMClient_submitToPublicAPI, $a1f6b3ef69eb7cc7$var$_MicroMClient_isPublicAPI;
1491
1491
  const $a1f6b3ef69eb7cc7$var$ENABLED_MENUS_DATA_KEY = "mm_menus";
1492
1492
  const $a1f6b3ef69eb7cc7$var$REMEMBER_USER_DATA_KEY = "mm_remember_me";
1493
1493
  const $a1f6b3ef69eb7cc7$var$TIMEZONE_OFFSET_DATA_KEY = "mm_server_timezone_offset";
1494
+ const $a1f6b3ef69eb7cc7$var$LOCAL_DEVICE_ID_KEY = "mm_ldid";
1494
1495
  class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1495
1496
  constructor({ api_url: api_url, app_id: app_id, login_timeout: login_timeout, mode: mode, tokenStorage: tokenStorage, publicEndpoints: publicEndpoints, dataStorage: dataStorage, redirect_on_401: redirect_on_401 }){
1496
1497
  $a1f6b3ef69eb7cc7$var$_MicroMClient_instances.add(this);
@@ -1500,6 +1501,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1500
1501
  $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT.set(this, void 0);
1501
1502
  $a1f6b3ef69eb7cc7$var$_MicroMClient_REQUEST_MODE.set(this, void 0);
1502
1503
  $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN.set(this, null);
1504
+ $a1f6b3ef69eb7cc7$var$_MicroMClient_LOCAL_DEVICE_ID.set(this, null);
1503
1505
  $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress.set(this, null);
1504
1506
  $a1f6b3ef69eb7cc7$var$_MicroMClient_publicEndpoints.set(this, {});
1505
1507
  $a1f6b3ef69eb7cc7$var$_MicroMClient_DATA_STORAGE.set(this, void 0);
@@ -1622,6 +1624,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1622
1624
  const loginTimeout = new (0, $dF8o7.TimeoutSignal)($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT, "f"), "Login request timed out");
1623
1625
  try {
1624
1626
  if ($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS, "f")) $a1f6b3ef69eb7cc7$var$__classPrivateFieldSet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORDED_PATHS, {}, "f");
1627
+ const localDeviceId = yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_instances, "m", $a1f6b3ef69eb7cc7$var$_MicroMClient_getLocalDeviceId).call(this);
1625
1628
  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`, {
1626
1629
  method: "POST",
1627
1630
  headers: {
@@ -1634,7 +1637,8 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1634
1637
  signal: loginTimeout.signal,
1635
1638
  body: JSON.stringify({
1636
1639
  username: username,
1637
- password: password
1640
+ password: password,
1641
+ LocalDeviceId: localDeviceId
1638
1642
  })
1639
1643
  });
1640
1644
  if (!response.ok) throw {
@@ -1668,10 +1672,10 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1668
1672
  url: response.url
1669
1673
  };
1670
1674
  } catch (error) {
1675
+ console.warn("Login error", error);
1671
1676
  try {
1672
1677
  yield this.logoff();
1673
1678
  } catch (_a) {}
1674
- if (!(error instanceof Error && error.name === "AbortError")) //console.log(error);
1675
1679
  throw error;
1676
1680
  } finally{
1677
1681
  loginTimeout.clear();
@@ -1919,7 +1923,7 @@ class $a1f6b3ef69eb7cc7$export$6118e57c65bf19ee {
1919
1923
  return fileGuid ? `${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL, "f")}/${$a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f")}/thumbnail/${fileGuid}/${max_size}/${quality}` : "";
1920
1924
  }
1921
1925
  }
1922
- $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN_STORAGE = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_REQUEST_MODE = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_publicEndpoints = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_DATA_STORAGE = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_ENABLED_MENUS = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORDED_PATHS = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_REDIRECT_ON_401 = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_TIMEZONE_OFFSET = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_instances = new WeakSet(), $a1f6b3ef69eb7cc7$var$_MicroMClient_recordAccess = function _MicroMClient_recordAccess({ entityName: entityName, access: access, views: views, procs: procs, actions: actions, lookups: lookups }) {
1926
+ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN_STORAGE = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_LOGIN_TIMEOUT = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_REQUEST_MODE = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_TOKEN = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_LOCAL_DEVICE_ID = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_tokenRefreshInProgress = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_publicEndpoints = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_DATA_STORAGE = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_ENABLED_MENUS = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORDED_PATHS = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_REDIRECT_ON_401 = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_TIMEZONE_OFFSET = new WeakMap(), $a1f6b3ef69eb7cc7$var$_MicroMClient_instances = new WeakSet(), $a1f6b3ef69eb7cc7$var$_MicroMClient_recordAccess = function _MicroMClient_recordAccess({ entityName: entityName, access: access, views: views, procs: procs, actions: actions, lookups: lookups }) {
1923
1927
  if ($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORD_PATHS, "f")) {
1924
1928
  const rec = $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_RECORDED_PATHS, "f")[entityName];
1925
1929
  if (rec) {
@@ -1964,6 +1968,19 @@ $a1f6b3ef69eb7cc7$var$_MicroMClient_API_URL = new WeakMap(), $a1f6b3ef69eb7cc7$v
1964
1968
  console.log(result);
1965
1969
  }
1966
1970
  });
1971
+ }, $a1f6b3ef69eb7cc7$var$_MicroMClient_getLocalDeviceId = function _MicroMClient_getLocalDeviceId() {
1972
+ return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1973
+ const local_device = yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_DATA_STORAGE, "f").readData($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f"), $a1f6b3ef69eb7cc7$var$LOCAL_DEVICE_ID_KEY);
1974
+ if (local_device !== null) {
1975
+ $a1f6b3ef69eb7cc7$var$__classPrivateFieldSet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOCAL_DEVICE_ID, local_device, "f");
1976
+ return local_device;
1977
+ }
1978
+ // Generate a new local device ID if it doesn't exist
1979
+ const randomId = "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c)=>(+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16));
1980
+ yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_DATA_STORAGE, "f").saveData($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f"), $a1f6b3ef69eb7cc7$var$LOCAL_DEVICE_ID_KEY, randomId);
1981
+ $a1f6b3ef69eb7cc7$var$__classPrivateFieldSet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_LOCAL_DEVICE_ID, randomId, "f");
1982
+ return randomId;
1983
+ });
1967
1984
  }, $a1f6b3ef69eb7cc7$var$_MicroMClient_saveTimeZoneOffset = function _MicroMClient_saveTimeZoneOffset(data) {
1968
1985
  return $a1f6b3ef69eb7cc7$var$__awaiter(this, void 0, void 0, function*() {
1969
1986
  yield $a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_DATA_STORAGE, "f").saveData($a1f6b3ef69eb7cc7$var$__classPrivateFieldGet(this, $a1f6b3ef69eb7cc7$var$_MicroMClient_APP_ID, "f"), $a1f6b3ef69eb7cc7$var$TIMEZONE_OFFSET_DATA_KEY, data);