@overmap-ai/core 1.0.60-sdk-refactor.14 → 1.0.60-sdk-refactor.16

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.
@@ -15082,7 +15082,6 @@ function extractResponseFromError(error2) {
15082
15082
  }
15083
15083
  async function performRequest(action, client) {
15084
15084
  const serviceOfRequest = CLASS_NAME_TO_SERVICE[action.meta.offline.effect.serviceName];
15085
- console.debug(CLASS_NAME_TO_SERVICE, action.meta.offline.effect.serviceName, serviceOfRequest);
15086
15085
  if (!serviceOfRequest) {
15087
15086
  throw new Error(`Service ${action.meta.offline.effect.serviceName} not found`);
15088
15087
  }
@@ -15463,19 +15462,15 @@ class JWTService extends BaseAuthService {
15463
15462
  checkAuth: false,
15464
15463
  // Don't wait for other requests to finish, or we might end up in a deadlock.
15465
15464
  immediate: true
15466
- }).catch((e) => {
15467
- console.error("Could not renew tokens; logging out due to error:", e);
15468
- this.clearAuth();
15469
- return void 0;
15470
15465
  });
15471
15466
  let response = void 0;
15472
15467
  try {
15473
15468
  response = await promise;
15474
15469
  } catch (e) {
15470
+ console.error("Could not renew tokens; clearing auth", e);
15475
15471
  this.clearAuth();
15476
- }
15477
- if (!response)
15478
15472
  return void 0;
15473
+ }
15479
15474
  if (!response.access)
15480
15475
  throw new Error("Missing access token");
15481
15476
  if (!response.refresh)
@@ -15487,6 +15482,7 @@ class JWTService extends BaseAuthService {
15487
15482
  * Logs the user out
15488
15483
  */
15489
15484
  clearAuth() {
15485
+ console.debug(this.constructor.name, "clearing auth;");
15490
15486
  this.dispatch(setLoggedIn(false));
15491
15487
  this.clearTokens();
15492
15488
  this.dispatch(setActiveProjectId(null));
@@ -15502,6 +15498,7 @@ class JWTService extends BaseAuthService {
15502
15498
  if (!dyingRefreshToken) {
15503
15499
  throw new Error("No refresh token found");
15504
15500
  }
15501
+ console.debug(this.constructor.name, "renewing tokens");
15505
15502
  try {
15506
15503
  const tokens = await this._getRenewedTokens(dyingRefreshToken);
15507
15504
  if (!tokens) {
@@ -15510,15 +15507,11 @@ class JWTService extends BaseAuthService {
15510
15507
  console.log("Got renewed tokens");
15511
15508
  this.setTokens(tokens);
15512
15509
  } catch (e) {
15513
- console.error("Could not renew tokens; logging out.");
15510
+ console.error("Could not renew tokens; clearing auth", e);
15514
15511
  this.clearAuth();
15515
15512
  throw e;
15516
15513
  }
15517
15514
  }
15518
- /**
15519
- * Checks whether the tokens will be expiring soon
15520
- * @returns {boolean}
15521
- */
15522
15515
  tokenIsExpiringSoon() {
15523
15516
  const accessToken = this.getAccessToken();
15524
15517
  if (!accessToken) {
@@ -15536,12 +15529,12 @@ class JWTService extends BaseAuthService {
15536
15529
  }
15537
15530
  getAuthHeader() {
15538
15531
  const accessToken = this.getAccessToken();
15539
- console.debug("getAuthHeader", accessToken);
15540
15532
  return `Bearer ${accessToken}`;
15541
15533
  }
15542
15534
  async prepareAuth() {
15543
15535
  if (!this.tokenIsExpiringSoon())
15544
15536
  return;
15537
+ console.debug(this.constructor.name, "preparing auth");
15545
15538
  try {
15546
15539
  await this.renewTokens();
15547
15540
  } catch (e) {
@@ -15578,6 +15571,7 @@ class JWTService extends BaseAuthService {
15578
15571
  }
15579
15572
  async initAuth(payload) {
15580
15573
  const uuid = v4();
15574
+ console.debug(this.constructor.name, "Initiating auth");
15581
15575
  const promise = this.enqueueRequest({
15582
15576
  uuid,
15583
15577
  description: "Get token pair",