@sambath999/localize-token 12.3.4 → 12.3.6

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.
@@ -565,29 +565,33 @@
565
565
 
566
566
  var LocalizeTokenService = /** @class */ (function () {
567
567
  function LocalizeTokenService() {
568
+ this.configSubject = new rxjs.BehaviorSubject({});
568
569
  this.isRevokingTokenSubject = new rxjs.BehaviorSubject(false);
569
570
  this.defaultConfig = {
570
571
  mainDomain: extractMainDomain(),
571
572
  authTokenName: 'auth-token',
572
573
  refreshTokenName: '_lze_rftkp_',
573
574
  };
574
- this._config = Object.assign({}, this.defaultConfig);
575
575
  this.isInitialized = false;
576
576
  this.decodeToken = function (token) { return jwt_decode__namespace.jwtDecode(token); };
577
577
  }
578
578
  Object.defineProperty(LocalizeTokenService.prototype, "config", {
579
579
  get: function () {
580
580
  this.throwIfNotInitialized();
581
- return this._config;
581
+ return this.configSubject.value;
582
582
  },
583
583
  enumerable: false,
584
584
  configurable: true
585
585
  });
586
586
  LocalizeTokenService.prototype.init = function (config) {
587
- console.warn('LocalizeTokenService is initialized.');
588
- this._config = Object.assign(Object.assign({}, this.defaultConfig), config);
587
+ console.log('LocalizeTokenService is initialized.');
588
+ this.configSubject.next(Object.assign(Object.assign({}, this.defaultConfig), config));
589
589
  this.isInitialized = true;
590
590
  };
591
+ LocalizeTokenService.prototype.ngOnDestroy = function () {
592
+ // this.configSubject.complete();
593
+ // this.isRevokingTokenSubject.complete();
594
+ };
591
595
  Object.defineProperty(LocalizeTokenService.prototype, "authToken", {
592
596
  get: function () { return this.storageGet(); },
593
597
  set: function (value) {
@@ -886,9 +890,10 @@
886
890
  this.httpClient = httpClient;
887
891
  this.localizeTokenService = localizeTokenService;
888
892
  this.destroy$ = new rxjs.Subject();
893
+ this.configSubject = new rxjs.BehaviorSubject({});
889
894
  this.isRequestingSubject = new rxjs.BehaviorSubject(false);
890
895
  this.isResolvingStartupSubject = new rxjs.BehaviorSubject(false);
891
- this.config = {
896
+ this.defaultConfig = {
892
897
  waitEachRequest: { milliseconds: 0 },
893
898
  enableRequestCancellation: true,
894
899
  retryOptions: {
@@ -950,14 +955,21 @@
950
955
  enumerable: false,
951
956
  configurable: true
952
957
  });
958
+ Object.defineProperty(LocalizeApiService.prototype, "config", {
959
+ get: function () {
960
+ this.validateConfig();
961
+ return this.configSubject.value;
962
+ },
963
+ enumerable: false,
964
+ configurable: true
965
+ });
953
966
  /**
954
967
  * Initialize the API service.
955
968
  * @param apiConfigs - The API configurations.
956
969
  */
957
970
  LocalizeApiService.prototype.init = function (apiConfigs) {
958
- console.warn('LocalizeApiService is initialized.');
959
- this.config = Object.assign(Object.assign({}, this.config), apiConfigs);
960
- this.validateConfig(this.config);
971
+ console.log('LocalizeApiService is initialized.');
972
+ this.configSubject.next(Object.assign(Object.assign({}, this.defaultConfig), apiConfigs));
961
973
  };
962
974
  LocalizeApiService.prototype.cancelPendingRequests = function () {
963
975
  this.config.enableRequestCancellation
@@ -966,6 +978,9 @@
966
978
  LocalizeApiService.prototype.ngOnDestroy = function () {
967
979
  this.destroy$.next();
968
980
  this.destroy$.complete();
981
+ // this.isResolvingStartupSubject.complete();
982
+ // this.isRequestingSubject.complete();
983
+ // this.configSubject.complete();
969
984
  };
970
985
  LocalizeApiService.prototype.request = function (baseUrl, path, method, reqBody, reqHeaders) {
971
986
  if (method === void 0) { method = exports.EMethod.GET; }
@@ -1190,8 +1205,9 @@
1190
1205
  });
1191
1206
  });
1192
1207
  };
1193
- LocalizeApiService.prototype.validateConfig = function (config) {
1208
+ LocalizeApiService.prototype.validateConfig = function () {
1194
1209
  var _a;
1210
+ var config = this.configSubject.value;
1195
1211
  if (this.localizeTokenService.config.needTenant && !((_a = config.tenantTokenName) === null || _a === void 0 ? void 0 : _a.trim().length)) {
1196
1212
  throw Error('Tenant token is required but tenantTokenName is not configured');
1197
1213
  }