@sambath999/localize-token 12.2.6 → 12.2.7

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.
@@ -481,23 +481,16 @@
481
481
 
482
482
  var LocalizeToken = /** @class */ (function () {
483
483
  function LocalizeToken() {
484
- this.configSubject = new rxjs.BehaviorSubject(LocalizeToken.config);
485
484
  }
486
- Object.defineProperty(LocalizeToken.prototype, "getConfig", {
487
- get: function () { return this.configSubject.value; },
488
- enumerable: false,
489
- configurable: true
490
- });
491
485
  LocalizeToken.init = function (config) {
492
- var lConfig = new LocalizeToken();
493
486
  LocalizeToken.config = Object.assign(Object.assign({}, LocalizeToken.config), config);
494
- lConfig.configSubject.next(LocalizeToken.config);
495
487
  };
496
488
  return LocalizeToken;
497
489
  }());
498
490
  LocalizeToken.config = {
499
491
  mainDomain: extractMainDomain(),
500
492
  authTokenName: 'auth-token',
493
+ tenantTokenName: '_lze_tnt_01',
501
494
  refreshTokenName: '_lze_rftkp_',
502
495
  needTenant: false,
503
496
  isProduction: false,
@@ -583,21 +576,14 @@
583
576
  }
584
577
 
585
578
  var LocalizeTokenService = /** @class */ (function () {
586
- function LocalizeTokenService(tokenConfig) {
587
- this.tokenConfig = tokenConfig;
579
+ function LocalizeTokenService() {
588
580
  this.isRevokingTokenSubject = new rxjs.BehaviorSubject(false);
589
581
  this.decodeToken = function (token) { return jwt_decode__namespace.jwtDecode(token); };
590
- // if (!this.tokenConfig.getConfig.authTokenName || !this.tokenConfig.getConfig.refreshTokenName || !this.tokenConfig.getConfig.tenantTokenName) {
591
- // throw new Error('authTokenName, refreshTokenName, and tenantTokenName must be defined in LocalizeToken.config')
592
- // }
593
- // this.config = this.tokenConfig.getConfig;
582
+ if (!LocalizeToken.config.authTokenName || !LocalizeToken.config.refreshTokenName || !LocalizeToken.config.tenantTokenName) {
583
+ throw new Error('authTokenName, refreshTokenName, and tenantTokenName must be defined in LocalizeToken.config');
584
+ }
585
+ this.config = LocalizeToken.config;
594
586
  }
595
- Object.defineProperty(LocalizeTokenService.prototype, "config", {
596
- // private readonly config: ILocalizeTokenConfig
597
- get: function () { return this.tokenConfig.getConfig; },
598
- enumerable: false,
599
- configurable: true
600
- });
601
587
  Object.defineProperty(LocalizeTokenService.prototype, "authToken", {
602
588
  get: function () { return this.storageGet(); },
603
589
  set: function (value) {
@@ -634,7 +620,14 @@
634
620
  enumerable: false,
635
621
  configurable: true
636
622
  });
637
- LocalizeTokenService.prototype.tenantToken = function () { return LocalizeToken.storage.get(this.config.tenantTokenName); };
623
+ Object.defineProperty(LocalizeTokenService.prototype, "getTenantToken", {
624
+ get: function () { return LocalizeToken.storage.get(this.config.tenantTokenName); },
625
+ enumerable: false,
626
+ configurable: true
627
+ });
628
+ LocalizeTokenService.prototype.tenantToken = function (name) {
629
+ return LocalizeToken.storage.get(name);
630
+ };
638
631
  LocalizeTokenService.prototype.storageGet = function () {
639
632
  try {
640
633
  var encoded = LocalizeToken.storage.get(this.config.authTokenName);
@@ -651,7 +644,7 @@
651
644
  };
652
645
  LocalizeTokenService.prototype.tokensValid = function () {
653
646
  var _a, _b;
654
- return ((_a = this.refreshToken) === null || _a === void 0 ? void 0 : _a.length) && (!this.config.needTenant || ((_b = this.tenantToken()) === null || _b === void 0 ? void 0 : _b.length));
647
+ return ((_a = this.refreshToken) === null || _a === void 0 ? void 0 : _a.length) && (!this.config.needTenant || ((_b = this.getTenantToken) === null || _b === void 0 ? void 0 : _b.length));
655
648
  };
656
649
  Object.defineProperty(LocalizeTokenService.prototype, "decodeRefreshToken", {
657
650
  get: function () {
@@ -665,13 +658,11 @@
665
658
  });
666
659
  return LocalizeTokenService;
667
660
  }());
668
- LocalizeTokenService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeTokenService_Factory() { return new LocalizeTokenService(i0__namespace.ɵɵinject(LocalizeToken)); }, token: LocalizeTokenService, providedIn: "root" });
661
+ LocalizeTokenService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeTokenService_Factory() { return new LocalizeTokenService(); }, token: LocalizeTokenService, providedIn: "root" });
669
662
  LocalizeTokenService.decorators = [
670
663
  { type: i0.Injectable, args: [{ providedIn: 'root' },] }
671
664
  ];
672
- LocalizeTokenService.ctorParameters = function () { return [
673
- { type: LocalizeToken }
674
- ]; };
665
+ LocalizeTokenService.ctorParameters = function () { return []; };
675
666
 
676
667
  /**
677
668
  * Http method options
@@ -685,10 +676,9 @@
685
676
  EMethod[EMethod["PATCH"] = 5] = "PATCH";
686
677
  })(exports.EMethod || (exports.EMethod = {}));
687
678
  var LocalizeApiService = /** @class */ (function () {
688
- function LocalizeApiService(httpClient, tokenConfig, localizeTokenService) {
679
+ function LocalizeApiService(httpClient, localizeTokenService) {
689
680
  var _this = this;
690
681
  this.httpClient = httpClient;
691
- this.tokenConfig = tokenConfig;
692
682
  this.localizeTokenService = localizeTokenService;
693
683
  this.isRequestingSubject = new rxjs.BehaviorSubject(false);
694
684
  this.isResolvedStartupSubject = new rxjs.BehaviorSubject(false);
@@ -716,20 +706,12 @@
716
706
  enumerable: false,
717
707
  configurable: true
718
708
  });
719
- Object.defineProperty(LocalizeApiService.prototype, "config", {
720
- get: function () { return this.tokenConfig.getConfig; },
721
- enumerable: false,
722
- configurable: true
723
- });
724
709
  /**
725
710
  * Initialize the API service.
726
711
  * @param apiConfigs - The API configurations.
727
712
  */
728
713
  LocalizeApiService.prototype.init = function (apiConfigs) {
729
714
  this.apiConfigs = apiConfigs;
730
- if (apiConfigs.tenantTokenName) {
731
- this.tokenConfig.configSubject.next(Object.assign(Object.assign({}, this.config), { tenantTokenName: apiConfigs.tenantTokenName }));
732
- }
733
715
  };
734
716
  LocalizeApiService.prototype.base = function (baseUrl, path, method, value, isFormData, headers) {
735
717
  if (method === void 0) { method = exports.EMethod.GET; }
@@ -839,7 +821,7 @@
839
821
  case 2:
840
822
  _b.trys.push([2, , 10, 11]);
841
823
  this.localizeTokenService.isRevokingToken = true;
842
- reqUrl_1 = this.config.revokeTokenUrl;
824
+ reqUrl_1 = LocalizeToken.config.revokeTokenUrl;
843
825
  reqHeaders_1 = this.options().append(LocalizeToken.httpHeaders.X_REFRESH_TOKEN, "" + this.localizeTokenService.refreshToken);
844
826
  return [4 /*yield*/, new Promise(function (resolve, reject) { return _this.httpClient.get(reqUrl_1, { headers: reqHeaders_1 }).subscribe({ next: resolve, error: reject }); })];
845
827
  case 3:
@@ -877,8 +859,8 @@
877
859
  if (isFormData === void 0) { isFormData = false; }
878
860
  if (headers === void 0) { headers = {}; }
879
861
  var defaultHeaders = (_b = {}, _b[LocalizeToken.httpHeaders.AUTHORIZATION] = "Bearer " + this.localizeTokenService.accessToken, _b);
880
- if (this.config.needTenant) {
881
- defaultHeaders[LocalizeToken.httpHeaders.X_TENANT] = "" + this.localizeTokenService.tenantToken();
862
+ if (LocalizeToken.config.needTenant) {
863
+ defaultHeaders[LocalizeToken.httpHeaders.X_TENANT] = "" + this.localizeTokenService.tenantToken(this.apiConfigs.tenantTokenName);
882
864
  }
883
865
  if (!isFormData) {
884
866
  defaultHeaders[LocalizeToken.httpHeaders.CONTENT_TYPE] = 'application/json';
@@ -914,7 +896,7 @@
914
896
  };
915
897
  return LocalizeApiService;
916
898
  }()); //class
917
- LocalizeApiService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeApiService_Factory() { return new LocalizeApiService(i0__namespace.ɵɵinject(i1__namespace.HttpClient), i0__namespace.ɵɵinject(LocalizeToken), i0__namespace.ɵɵinject(LocalizeTokenService)); }, token: LocalizeApiService, providedIn: "root" });
899
+ LocalizeApiService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeApiService_Factory() { return new LocalizeApiService(i0__namespace.ɵɵinject(i1__namespace.HttpClient), i0__namespace.ɵɵinject(LocalizeTokenService)); }, token: LocalizeApiService, providedIn: "root" });
918
900
  LocalizeApiService.decorators = [
919
901
  { type: i0.Injectable, args: [{
920
902
  providedIn: 'root'
@@ -922,7 +904,6 @@
922
904
  ];
923
905
  LocalizeApiService.ctorParameters = function () { return [
924
906
  { type: i1.HttpClient },
925
- { type: LocalizeToken },
926
907
  { type: LocalizeTokenService }
927
908
  ]; };
928
909
 
@@ -935,14 +916,13 @@
935
916
  { type: i0.NgModule, args: [{
936
917
  providers: [
937
918
  LocalizeTokenService,
938
- LocalizeApiService,
939
- LocalizeToken
919
+ LocalizeApiService
940
920
  ],
941
921
  },] }
942
922
  ];
943
923
 
944
924
  var LocalizeLogindlgComponent = /** @class */ (function () {
945
- function LocalizeLogindlgComponent(messageService, cdt, dlgRef, dlgConfig, tokenService, httpClient, tokenConfig) {
925
+ function LocalizeLogindlgComponent(messageService, cdt, dlgRef, dlgConfig, tokenService, httpClient) {
946
926
  var _this = this;
947
927
  this.messageService = messageService;
948
928
  this.cdt = cdt;
@@ -950,19 +930,14 @@
950
930
  this.dlgConfig = dlgConfig;
951
931
  this.tokenService = tokenService;
952
932
  this.httpClient = httpClient;
953
- this.tokenConfig = tokenConfig;
954
933
  this.messageKey = "$login-dlg";
955
934
  this.loading = false;
956
935
  this.success = false;
936
+ this.config = LocalizeToken.config;
957
937
  this.clickLogout = function () { var _a; return (_a = _this.logout) === null || _a === void 0 ? void 0 : _a.call(_this); };
958
938
  this.decodeToken = this.tokenService.decodeRefreshToken;
959
939
  this.loginConfig = this.dlgConfig.data.loginConfig;
960
940
  }
961
- Object.defineProperty(LocalizeLogindlgComponent.prototype, "config", {
962
- get: function () { return this.tokenConfig.getConfig; },
963
- enumerable: false,
964
- configurable: true
965
- });
966
941
  LocalizeLogindlgComponent.prototype.ngOnInit = function () {
967
942
  var _this = this;
968
943
  this.dlgConfig.closable = false;
@@ -1069,8 +1044,7 @@
1069
1044
  { type: dynamicdialog.DynamicDialogRef },
1070
1045
  { type: dynamicdialog.DynamicDialogConfig },
1071
1046
  { type: LocalizeTokenService },
1072
- { type: i1.HttpClient },
1073
- { type: LocalizeToken }
1047
+ { type: i1.HttpClient }
1074
1048
  ]; };
1075
1049
 
1076
1050
  var LocalizeLogindlgService = /** @class */ (function () {