@coscine/api-client 1.3.0 → 1.4.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.umd.js CHANGED
@@ -8483,7 +8483,14 @@
8483
8483
 
8484
8484
  let accessToken = '';
8485
8485
  if (typeof coscine !== 'undefined' && typeof coscine.authorization !== 'undefined') {
8486
- accessToken = coscine.authorization.bearer;
8486
+ accessToken = 'Bearer ' + coscine.authorization.bearer;
8487
+ }
8488
+ if (typeof window !== 'undefined') {
8489
+ // LocalStorage > Global Variables
8490
+ const localStorageToken = localStorage.getItem('coscine.authorization.bearer');
8491
+ if (localStorageToken) {
8492
+ accessToken = 'Bearer ' + localStorageToken;
8493
+ }
8487
8494
  }
8488
8495
  const getHostName = () => {
8489
8496
  let hostName = typeof window !== 'undefined' ? window.location.hostname : 'coscine.rwth-aachen.de';
@@ -8538,25 +8545,53 @@
8538
8545
  request.headers.common[clientCorrolationIdKey] = coscine.clientcorrolation.id;
8539
8546
  }
8540
8547
  }
8548
+ if (typeof window !== 'undefined') {
8549
+ // LocalStorage > Global Variables
8550
+ const localStorageToken = localStorage.getItem("coscine.authorization.bearer");
8551
+ if (localStorageToken) {
8552
+ request.headers.common[authHeaderKey] =
8553
+ 'Bearer ' + localStorageToken;
8554
+ }
8555
+ const localStorageClientCorrelation = localStorage.getItem("coscine.clientcorrolation.id");
8556
+ if (localStorageClientCorrelation) {
8557
+ request.headers.common[clientCorrolationIdKey] = localStorageClientCorrelation;
8558
+ }
8559
+ }
8541
8560
  }
8542
- instance.interceptors.request.use((request) => {
8543
- setHeader(request);
8561
+ function increaseLoading() {
8544
8562
  if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
8545
8563
  coscine.loading.counter++;
8546
8564
  }
8565
+ if (typeof window !== 'undefined') {
8566
+ const localStorageLoading = localStorage.getItem("coscine.loading.counter");
8567
+ if (localStorageLoading) {
8568
+ localStorage.setItem("coscine.loading.counter", String(Number(localStorageLoading) + 1));
8569
+ }
8570
+ }
8571
+ }
8572
+ function decreaseLoading() {
8573
+ if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
8574
+ coscine.loading.counter--;
8575
+ }
8576
+ if (typeof window !== 'undefined') {
8577
+ const localStorageLoading = localStorage.getItem("coscine.loading.counter");
8578
+ if (localStorageLoading) {
8579
+ localStorage.setItem("coscine.loading.counter", String(Number(localStorageLoading) - 1));
8580
+ }
8581
+ }
8582
+ }
8583
+ instance.interceptors.request.use((request) => {
8584
+ setHeader(request);
8585
+ increaseLoading();
8547
8586
  return request;
8548
8587
  }, (error) => {
8549
8588
  return Promise.reject(error);
8550
8589
  });
8551
8590
  instance.interceptors.response.use((response) => {
8552
- if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
8553
- coscine.loading.counter--;
8554
- }
8591
+ decreaseLoading();
8555
8592
  return response;
8556
8593
  }, (error) => {
8557
- if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
8558
- coscine.loading.counter--;
8559
- }
8594
+ decreaseLoading();
8560
8595
  return Promise.reject(error);
8561
8596
  });
8562
8597
 
@@ -8612,6 +8647,8 @@
8612
8647
  exports.TreeApi = TreeApi;
8613
8648
  exports.UserApi = UserApi;
8614
8649
  exports.VisibilityApi = VisibilityApi;
8650
+ exports.apiImplementations = implementations;
8651
+ exports.axiosInstance = instance;
8615
8652
  exports["default"] = apis;
8616
8653
 
8617
8654
  Object.defineProperty(exports, '__esModule', { value: true });