@orbis-systems/orbis-api-clients 0.5.0 → 0.5.2

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.
@@ -234,8 +234,8 @@ class $538ed1203bac2e79$export$f280b732bbc5934b extends (0, $3621850f1f570615$ex
234
234
  }
235
235
  if (this.config.autoRenewToken !== false && this.isTokenExpired(accessToken)) try {
236
236
  await this.lock.runExclusive(async ()=>{
237
- (0, $6VTA9$consola.consola).info("Token expired. Renewing\u2026");
238
- await this.renewToken();
237
+ if (this.config.debug) (0, $6VTA9$consola.consola).debug("Token expired. Renewing\u2026");
238
+ accessToken = (await this.renewToken()).accessToken;
239
239
  this.lock.cancel();
240
240
  });
241
241
  } catch (error) {
@@ -254,9 +254,11 @@ class $538ed1203bac2e79$export$f280b732bbc5934b extends (0, $3621850f1f570615$ex
254
254
  return (0, $6VTA9$datefns.isBefore)((0, $6VTA9$datefns.subMinutes)(payload.exp * 1000, 5), Date.now());
255
255
  }
256
256
  async renewToken() {
257
- if (!this.renewTokenCallback) throw new Error('No renew token callback provided');
258
- const authData = await this.renewTokenCallback();
257
+ const callback = this.config.onRenewToken ?? this.renewTokenCallback;
258
+ if (!callback) throw new Error('No renew token callback provided');
259
+ const authData = await callback();
259
260
  this.setAuthData(authData);
261
+ return authData;
260
262
  }
261
263
  }
262
264