@sambath999/localize-token 12.2.5 → 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,11 +706,6 @@
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.
@@ -836,7 +821,7 @@
836
821
  case 2:
837
822
  _b.trys.push([2, , 10, 11]);
838
823
  this.localizeTokenService.isRevokingToken = true;
839
- reqUrl_1 = this.config.revokeTokenUrl;
824
+ reqUrl_1 = LocalizeToken.config.revokeTokenUrl;
840
825
  reqHeaders_1 = this.options().append(LocalizeToken.httpHeaders.X_REFRESH_TOKEN, "" + this.localizeTokenService.refreshToken);
841
826
  return [4 /*yield*/, new Promise(function (resolve, reject) { return _this.httpClient.get(reqUrl_1, { headers: reqHeaders_1 }).subscribe({ next: resolve, error: reject }); })];
842
827
  case 3:
@@ -874,8 +859,8 @@
874
859
  if (isFormData === void 0) { isFormData = false; }
875
860
  if (headers === void 0) { headers = {}; }
876
861
  var defaultHeaders = (_b = {}, _b[LocalizeToken.httpHeaders.AUTHORIZATION] = "Bearer " + this.localizeTokenService.accessToken, _b);
877
- if (this.config.needTenant) {
878
- 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);
879
864
  }
880
865
  if (!isFormData) {
881
866
  defaultHeaders[LocalizeToken.httpHeaders.CONTENT_TYPE] = 'application/json';
@@ -911,7 +896,7 @@
911
896
  };
912
897
  return LocalizeApiService;
913
898
  }()); //class
914
- 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" });
915
900
  LocalizeApiService.decorators = [
916
901
  { type: i0.Injectable, args: [{
917
902
  providedIn: 'root'
@@ -919,7 +904,6 @@
919
904
  ];
920
905
  LocalizeApiService.ctorParameters = function () { return [
921
906
  { type: i1.HttpClient },
922
- { type: LocalizeToken },
923
907
  { type: LocalizeTokenService }
924
908
  ]; };
925
909
 
@@ -932,14 +916,13 @@
932
916
  { type: i0.NgModule, args: [{
933
917
  providers: [
934
918
  LocalizeTokenService,
935
- LocalizeApiService,
936
- LocalizeToken
919
+ LocalizeApiService
937
920
  ],
938
921
  },] }
939
922
  ];
940
923
 
941
924
  var LocalizeLogindlgComponent = /** @class */ (function () {
942
- function LocalizeLogindlgComponent(messageService, cdt, dlgRef, dlgConfig, tokenService, httpClient, tokenConfig) {
925
+ function LocalizeLogindlgComponent(messageService, cdt, dlgRef, dlgConfig, tokenService, httpClient) {
943
926
  var _this = this;
944
927
  this.messageService = messageService;
945
928
  this.cdt = cdt;
@@ -947,19 +930,14 @@
947
930
  this.dlgConfig = dlgConfig;
948
931
  this.tokenService = tokenService;
949
932
  this.httpClient = httpClient;
950
- this.tokenConfig = tokenConfig;
951
933
  this.messageKey = "$login-dlg";
952
934
  this.loading = false;
953
935
  this.success = false;
936
+ this.config = LocalizeToken.config;
954
937
  this.clickLogout = function () { var _a; return (_a = _this.logout) === null || _a === void 0 ? void 0 : _a.call(_this); };
955
938
  this.decodeToken = this.tokenService.decodeRefreshToken;
956
939
  this.loginConfig = this.dlgConfig.data.loginConfig;
957
940
  }
958
- Object.defineProperty(LocalizeLogindlgComponent.prototype, "config", {
959
- get: function () { return this.tokenConfig.getConfig; },
960
- enumerable: false,
961
- configurable: true
962
- });
963
941
  LocalizeLogindlgComponent.prototype.ngOnInit = function () {
964
942
  var _this = this;
965
943
  this.dlgConfig.closable = false;
@@ -1066,8 +1044,7 @@
1066
1044
  { type: dynamicdialog.DynamicDialogRef },
1067
1045
  { type: dynamicdialog.DynamicDialogConfig },
1068
1046
  { type: LocalizeTokenService },
1069
- { type: i1.HttpClient },
1070
- { type: LocalizeToken }
1047
+ { type: i1.HttpClient }
1071
1048
  ]; };
1072
1049
 
1073
1050
  var LocalizeLogindlgService = /** @class */ (function () {