@stemy/ngx-utils 12.2.18 → 12.2.20

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.
@@ -3211,8 +3211,8 @@
3211
3211
  // If we use token auth
3212
3212
  if (_this.client.renewTokenFunc && headers.has(authKey)) {
3213
3213
  var currentTime = new Date().getTime();
3214
- var userTokenTime = _this.storage.get("userTokenTime") || currentTime;
3215
- // And the last request was a long long time ago
3214
+ var userTokenTime = _this.getUserTokenTime() || currentTime;
3215
+ // And the last request was a long-long time ago
3216
3216
  if (currentTime - 600000 > userTokenTime) {
3217
3217
  _this.client.renewTokenFunc();
3218
3218
  }
@@ -3224,7 +3224,7 @@
3224
3224
  }
3225
3225
  var headers = options.headers;
3226
3226
  var authKey = "Authorization";
3227
- // If an authorization header exists and we still have an Unauthorized response prompt the user to log in again
3227
+ // If an authorization header exists, and we still have an Unauthorized response prompt the user to log in again
3228
3228
  if (headers.has(authKey) && response.status == 401) {
3229
3229
  var pushed = _this.pushFailedRequest(url, options, function () {
3230
3230
  options.headers = _this.makeHeaders(options.originalHeaders);
@@ -3239,6 +3239,9 @@
3239
3239
  });
3240
3240
  });
3241
3241
  };
3242
+ BaseHttpService.prototype.getUserTokenTime = function () {
3243
+ return this.storage.get("userTokenTime");
3244
+ };
3242
3245
  BaseHttpService.prototype.pushFailedRequest = function (url, options, req) {
3243
3246
  if (url.indexOf("tokens") >= 0)
3244
3247
  return false;
@@ -3283,13 +3286,8 @@
3283
3286
  };
3284
3287
  BaseHttpService.prototype.absoluteUrl = function (url, options) {
3285
3288
  return __awaiter(this, void 0, void 0, function () {
3286
- var absoluteUrl;
3287
3289
  return __generator(this, function (_c) {
3288
- absoluteUrl = this.parseUrl(url);
3289
- if (url == "api-docs") {
3290
- return [2 /*return*/, absoluteUrl.replace("/api", "")];
3291
- }
3292
- return [2 /*return*/, absoluteUrl];
3290
+ return [2 /*return*/, this.parseUrl(url)];
3293
3291
  });
3294
3292
  });
3295
3293
  };
@@ -3328,7 +3326,11 @@
3328
3326
  configurable: true
3329
3327
  });
3330
3328
  ApiService.prototype.url = function (url) {
3331
- return this.expressRequestUrl("/api/" + url);
3329
+ var baseUrl = this.expressRequestUrl("/api/" + url);
3330
+ if (url == "api-docs" || url == "socket") {
3331
+ return baseUrl.replace("/api/", "/");
3332
+ }
3333
+ return baseUrl;
3332
3334
  };
3333
3335
  ApiService.prototype.get = function (url, options, body) {
3334
3336
  return this.getPromise(url, options, body);