monkey-front-core 0.0.304 → 0.0.306

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.
Files changed (28) hide show
  1. package/esm2020/lib/core/directives/monkeyecx-security-directive.mjs +9 -7
  2. package/esm2020/lib/core/interceptors/monkeyecx-http-config-error.interceptor.mjs +1 -1
  3. package/esm2020/lib/core/interceptors/monkeyecx-http-config-header.interceptor.mjs +9 -10
  4. package/esm2020/lib/core/services/auth/monkeyecx-auth-guard-company.service.mjs +4 -4
  5. package/esm2020/lib/core/services/auth/monkeyecx-auth-guard-login.service.mjs +4 -4
  6. package/esm2020/lib/core/services/auth/monkeyecx-auth-guard.service.mjs +3 -3
  7. package/esm2020/lib/core/services/auth/monkeyecx-authentication.service.mjs +10 -5
  8. package/esm2020/lib/core/services/commons/monkeyecx-commons.service.mjs +11 -8
  9. package/esm2020/lib/core/services/error/monkeyecx-http-error-handling.service.mjs +4 -4
  10. package/esm2020/lib/core/services/storage/monkeyecx-token-storage.service.mjs +32 -15
  11. package/esm2020/lib/store/selectors/monkeyecx-storage.selector.mjs +2 -2
  12. package/fesm2015/monkey-front-core.mjs +233 -188
  13. package/fesm2015/monkey-front-core.mjs.map +1 -1
  14. package/fesm2020/monkey-front-core.mjs +98 -73
  15. package/fesm2020/monkey-front-core.mjs.map +1 -1
  16. package/lib/core/directives/monkeyecx-security-directive.d.ts +1 -0
  17. package/lib/core/interceptors/monkeyecx-http-config-header.interceptor.d.ts +2 -2
  18. package/lib/core/services/auth/monkeyecx-auth-guard-company.service.d.ts +1 -2
  19. package/lib/core/services/auth/monkeyecx-auth-guard-login.service.d.ts +1 -2
  20. package/lib/core/services/auth/monkeyecx-auth-guard.service.d.ts +1 -2
  21. package/lib/core/services/auth/monkeyecx-authentication.service.d.ts +6 -4
  22. package/lib/core/services/commons/monkeyecx-commons.service.d.ts +6 -6
  23. package/lib/core/services/error/monkeyecx-http-error-handling.service.d.ts +4 -4
  24. package/lib/core/services/storage/monkeyecx-token-storage.service.d.ts +23 -3
  25. package/lib/store/selectors/monkeyecx-storage.selector.d.ts +1 -1
  26. package/monkey-front-core-0.0.306.tgz +0 -0
  27. package/package.json +1 -1
  28. package/monkey-front-core-0.0.304.tgz +0 -0
@@ -19,10 +19,10 @@ import { NG_VALUE_ACCESSOR } from '@angular/forms';
19
19
  import { TemplatePortal } from '@angular/cdk/portal';
20
20
  import * as i1$4 from '@angular/cdk/overlay';
21
21
  import { OverlayModule } from '@angular/cdk/overlay';
22
+ import { __awaiter, __decorate } from 'tslib';
22
23
  import * as i2$3 from '@ngrx/store';
23
24
  import { createAction, props, INIT, UPDATE, createReducer, on, createFeatureSelector, createSelector, StoreModule } from '@ngrx/store';
24
25
  import { createEntityAdapter } from '@ngrx/entity';
25
- import { __awaiter, __decorate } from 'tslib';
26
26
  import { datadogRum } from '@datadog/browser-rum';
27
27
  import * as i1$5 from '@angular/service-worker';
28
28
  import { ServiceWorkerModule } from '@angular/service-worker';
@@ -2558,7 +2558,7 @@ const selectState = createFeatureSelector(featureKey);
2558
2558
  const selectAll = createSelector(selectState, selectAll$1);
2559
2559
  const select = (props) => {
2560
2560
  return createSelector(selectAll, (entities) => {
2561
- return entities.filter((_) => {
2561
+ return entities.find((_) => {
2562
2562
  return _.username === props.username;
2563
2563
  });
2564
2564
  });
@@ -2589,6 +2589,28 @@ var index = /*#__PURE__*/Object.freeze({
2589
2589
  selectors: index$1
2590
2590
  });
2591
2591
 
2592
+ class Link {
2593
+ constructor(data) {
2594
+ this.href = data === null || data === void 0 ? void 0 : data.href;
2595
+ this.type = data === null || data === void 0 ? void 0 : data.type;
2596
+ this.templated = data === null || data === void 0 ? void 0 : data.templated;
2597
+ }
2598
+ }
2599
+ class MonkeyEcxModel {
2600
+ getAction(type, replaceOptions) {
2601
+ const { _links } = this;
2602
+ if (!_links)
2603
+ return null;
2604
+ let link = _links[type.toLowerCase()];
2605
+ link = new Link(link);
2606
+ if (link && replaceOptions && (link === null || link === void 0 ? void 0 : link.templated)) {
2607
+ const { from, to } = replaceOptions;
2608
+ link = new Link(Object.assign(Object.assign({}, link), { href: `${link.href}`.replace(from, to) }));
2609
+ }
2610
+ return link;
2611
+ }
2612
+ }
2613
+
2592
2614
  class MonkeyEcxRequestPagedHandling {
2593
2615
  constructor(url, pagedParams, links, samePage = false) {
2594
2616
  this.samePage = false;
@@ -2630,28 +2652,6 @@ class MonkeyEcxRequestPagedHandling {
2630
2652
  }
2631
2653
  }
2632
2654
 
2633
- class Link {
2634
- constructor(data) {
2635
- this.href = data === null || data === void 0 ? void 0 : data.href;
2636
- this.type = data === null || data === void 0 ? void 0 : data.type;
2637
- this.templated = data === null || data === void 0 ? void 0 : data.templated;
2638
- }
2639
- }
2640
- class MonkeyEcxModel {
2641
- getAction(type, replaceOptions) {
2642
- const { _links } = this;
2643
- if (!_links)
2644
- return null;
2645
- let link = _links[type.toLowerCase()];
2646
- link = new Link(link);
2647
- if (link && replaceOptions && (link === null || link === void 0 ? void 0 : link.templated)) {
2648
- const { from, to } = replaceOptions;
2649
- link = new Link(Object.assign(Object.assign({}, link), { href: `${link.href}`.replace(from, to) }));
2650
- }
2651
- return link;
2652
- }
2653
- }
2654
-
2655
2655
  class LinksModel extends MonkeyEcxModel {
2656
2656
  constructor(data) {
2657
2657
  super();
@@ -2683,7 +2683,7 @@ class MonkeyEcxCommonsService {
2683
2683
  this.__onZipCodeDataChanged$ = new BehaviorSubject(null);
2684
2684
  this.__oni18nDataChanged$ = new BehaviorSubject(null);
2685
2685
  this.__onDoSearch$ = new BehaviorSubject({});
2686
- this.__tokenCredentials = null;
2686
+ this.__tokenCredentials = undefined;
2687
2687
  this.__schedule = null;
2688
2688
  this.__callbackPagination = () => {
2689
2689
  // eslint-disable-next-line no-console
@@ -2694,25 +2694,27 @@ class MonkeyEcxCommonsService {
2694
2694
  }
2695
2695
  handleInit() {
2696
2696
  var _a, _b, _c;
2697
- if (this.tokenStorage) {
2698
- this.__tokenCredentials = this.tokenStorage.getToken();
2699
- }
2700
- if ((_a = this.otherArgs) === null || _a === void 0 ? void 0 : _a.router) {
2701
- const { clearOnChangeRoute } = ((_c = (_b = this.otherArgs) === null || _b === void 0 ? void 0 : _b.schedule) === null || _c === void 0 ? void 0 : _c.options) || {
2702
- clearOnChangeRoute: false
2703
- };
2704
- this.otherArgs.router.events
2705
- .pipe(filter((event) => {
2706
- return event instanceof NavigationStart;
2707
- }), take(1))
2708
- .subscribe(() => {
2709
- var _a, _b, _c;
2710
- if (this.__schedule && clearOnChangeRoute) {
2711
- (_c = (_b = (_a = this.otherArgs) === null || _a === void 0 ? void 0 : _a.schedule) === null || _b === void 0 ? void 0 : _b.service) === null || _c === void 0 ? void 0 : _c.removeSchedule(this.__schedule);
2712
- this.__schedule = null;
2713
- }
2714
- });
2715
- }
2697
+ return __awaiter(this, void 0, void 0, function* () {
2698
+ if (this.tokenStorage) {
2699
+ this.__tokenCredentials = yield this.tokenStorage.getToken();
2700
+ }
2701
+ if ((_a = this.otherArgs) === null || _a === void 0 ? void 0 : _a.router) {
2702
+ const { clearOnChangeRoute } = ((_c = (_b = this.otherArgs) === null || _b === void 0 ? void 0 : _b.schedule) === null || _c === void 0 ? void 0 : _c.options) || {
2703
+ clearOnChangeRoute: false
2704
+ };
2705
+ this.otherArgs.router.events
2706
+ .pipe(filter((event) => {
2707
+ return event instanceof NavigationStart;
2708
+ }), take(1))
2709
+ .subscribe(() => {
2710
+ var _a, _b, _c;
2711
+ if (this.__schedule && clearOnChangeRoute) {
2712
+ (_c = (_b = (_a = this.otherArgs) === null || _a === void 0 ? void 0 : _a.schedule) === null || _b === void 0 ? void 0 : _b.service) === null || _c === void 0 ? void 0 : _c.removeSchedule(this.__schedule);
2713
+ this.__schedule = null;
2714
+ }
2715
+ });
2716
+ }
2717
+ });
2716
2718
  }
2717
2719
  navigateToPendencyPage(arg, router) {
2718
2720
  const { companyType } = this.__tokenCredentials || {
@@ -2875,77 +2877,82 @@ class MonkeyEcxCommonsService {
2875
2877
  }
2876
2878
  resolve(route, state, otherArgs) {
2877
2879
  var _a, _b, _c;
2878
- if (JSON.stringify(route === null || route === void 0 ? void 0 : route.queryParams) === '{}') {
2879
- this.__data = null;
2880
- this.__page = null;
2881
- }
2882
- this.__requestPaged = null;
2883
- this.flagValidator = true;
2884
- if (this.tokenStorage) {
2885
- this.__tokenCredentials = this.tokenStorage.getToken();
2886
- }
2887
- const pend = this.allowedSecurityAccessByPendency(otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.pendency);
2888
- const allowedByProgram = this.allowedSecurityAccessByFeature(otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.featureByProgram);
2889
- if (this.allowedSecurityAccess(otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.security) &&
2890
- this.allowedSecurityAccessByCountry(otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.countrySecurity) &&
2891
- !pend.hasPendencies &&
2892
- allowedByProgram) {
2893
- if (this.__schedule) {
2894
- (_c = (_b = (_a = this.otherArgs) === null || _a === void 0 ? void 0 : _a.schedule) === null || _b === void 0 ? void 0 : _b.service) === null || _c === void 0 ? void 0 : _c.removeSchedule(this.__schedule);
2895
- this.__schedule = null;
2896
- }
2897
- const { __requestPaged } = this;
2898
- if (!__requestPaged) {
2899
- this.setPage({
2900
- page: {
2901
- number: 0,
2902
- size: 10
2903
- }
2904
- });
2905
- }
2906
- if (otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.translateOptions) {
2907
- const { service, keys } = otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.translateOptions;
2908
- this.geti18n(service, keys || '');
2909
- }
2910
- if (otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.callbackPagination) {
2911
- this.__callbackPagination = otherArgs.callbackPagination;
2880
+ return __awaiter(this, void 0, void 0, function* () {
2881
+ if (JSON.stringify(route === null || route === void 0 ? void 0 : route.queryParams) === '{}') {
2882
+ this.__data = null;
2883
+ this.__page = null;
2912
2884
  }
2913
- if (otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.paginationOptions) {
2914
- this.__paginationOptions = otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.paginationOptions;
2915
- this.handlePaginationOptions();
2885
+ this.__requestPaged = null;
2886
+ this.flagValidator = true;
2887
+ if (this.tokenStorage) {
2888
+ console.log('resolve commmons');
2889
+ this.__tokenCredentials = yield this.tokenStorage.getToken();
2890
+ console.log('this.__tokenCredentials');
2891
+ console.log(this.__tokenCredentials);
2916
2892
  }
2917
- if (otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.feature) {
2918
- const { flag, service } = otherArgs.feature;
2919
- service.onFlags
2920
- .pipe(takeWhile(() => {
2921
- return this.flagValidator;
2922
- }))
2923
- .subscribe((val) => {
2924
- if (val) {
2925
- const hasFlag = service.getFlag(flag);
2926
- if (MonkeyEcxUtils.persistNullEmptyUndefined(hasFlag)) {
2927
- if (!hasFlag) {
2928
- this.navigateToErrorPage(404, otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.router);
2929
- return;
2893
+ const pend = this.allowedSecurityAccessByPendency(otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.pendency);
2894
+ const allowedByProgram = this.allowedSecurityAccessByFeature(otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.featureByProgram);
2895
+ if (this.allowedSecurityAccess(otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.security) &&
2896
+ this.allowedSecurityAccessByCountry(otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.countrySecurity) &&
2897
+ !pend.hasPendencies &&
2898
+ allowedByProgram) {
2899
+ if (this.__schedule) {
2900
+ (_c = (_b = (_a = this.otherArgs) === null || _a === void 0 ? void 0 : _a.schedule) === null || _b === void 0 ? void 0 : _b.service) === null || _c === void 0 ? void 0 : _c.removeSchedule(this.__schedule);
2901
+ this.__schedule = null;
2902
+ }
2903
+ const { __requestPaged } = this;
2904
+ if (!__requestPaged) {
2905
+ this.setPage({
2906
+ page: {
2907
+ number: 0,
2908
+ size: 10
2909
+ }
2910
+ });
2911
+ }
2912
+ if (otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.translateOptions) {
2913
+ const { service, keys } = otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.translateOptions;
2914
+ this.geti18n(service, keys || '');
2915
+ }
2916
+ if (otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.callbackPagination) {
2917
+ this.__callbackPagination = otherArgs.callbackPagination;
2918
+ }
2919
+ if (otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.paginationOptions) {
2920
+ this.__paginationOptions = otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.paginationOptions;
2921
+ this.handlePaginationOptions();
2922
+ }
2923
+ if (otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.feature) {
2924
+ const { flag, service } = otherArgs.feature;
2925
+ service.onFlags
2926
+ .pipe(takeWhile(() => {
2927
+ return this.flagValidator;
2928
+ }))
2929
+ .subscribe((val) => {
2930
+ if (val) {
2931
+ const hasFlag = service.getFlag(flag);
2932
+ if (MonkeyEcxUtils.persistNullEmptyUndefined(hasFlag)) {
2933
+ if (!hasFlag) {
2934
+ this.navigateToErrorPage(404, otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.router);
2935
+ return;
2936
+ }
2930
2937
  }
2938
+ otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.callbackMain();
2931
2939
  }
2932
- otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.callbackMain();
2933
- }
2934
- });
2940
+ });
2941
+ }
2942
+ else {
2943
+ otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.callbackMain();
2944
+ }
2945
+ }
2946
+ else if (!allowedByProgram) {
2947
+ this.navigateToErrorPage(404, otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.router);
2948
+ }
2949
+ else if (pend.hasPendencies) {
2950
+ this.navigateToPendencyPage(pend, otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.router);
2935
2951
  }
2936
2952
  else {
2937
- otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.callbackMain();
2953
+ this.navigateToErrorPage(403, otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.router);
2938
2954
  }
2939
- }
2940
- else if (!allowedByProgram) {
2941
- this.navigateToErrorPage(404, otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.router);
2942
- }
2943
- else if (pend.hasPendencies) {
2944
- this.navigateToPendencyPage(pend, otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.router);
2945
- }
2946
- else {
2947
- this.navigateToErrorPage(403, otherArgs === null || otherArgs === void 0 ? void 0 : otherArgs.router);
2948
- }
2955
+ });
2949
2956
  }
2950
2957
  getHTTPHeaderApplicationPDF() {
2951
2958
  return {
@@ -3645,15 +3652,27 @@ class MonkeyEcxTokenStorageService {
3645
3652
  }
3646
3653
  getAllTokens() {
3647
3654
  var _a;
3648
- const { token, config } = this;
3649
- const handledToken = Object.assign({}, token);
3650
- Object.entries(token || {}).forEach(([key, value]) => {
3651
- handledToken[key] = localStorage.getItem(key);
3655
+ return __awaiter(this, void 0, void 0, function* () {
3656
+ const { store, monkeyecxConfigService } = this;
3657
+ const username = localStorage.getItem('username');
3658
+ let data = {
3659
+ username: username || '',
3660
+ program: ''
3661
+ };
3662
+ if (username) {
3663
+ data = yield store.select(select({ username })).pipe(take(1)).toPromise();
3664
+ data === null || data === void 0 ? true : delete data.me;
3665
+ }
3666
+ const config = yield monkeyecxConfigService.config()
3667
+ .pipe(first((val) => {
3668
+ return !!val && JSON.stringify(val) !== '{}';
3669
+ }))
3670
+ .toPromise();
3671
+ if (data && !(data === null || data === void 0 ? void 0 : data.program) && (config === null || config === void 0 ? void 0 : config.program)) {
3672
+ data.program = (_a = config === null || config === void 0 ? void 0 : config.program) === null || _a === void 0 ? void 0 : _a.token;
3673
+ }
3674
+ return data;
3652
3675
  });
3653
- if (!(handledToken === null || handledToken === void 0 ? void 0 : handledToken.program) && (config === null || config === void 0 ? void 0 : config.program)) {
3654
- handledToken.program = (_a = config === null || config === void 0 ? void 0 : config.program) === null || _a === void 0 ? void 0 : _a.token;
3655
- }
3656
- return handledToken;
3657
3676
  }
3658
3677
  setAllMe(me) {
3659
3678
  const { me$, store } = this;
@@ -3678,8 +3697,18 @@ class MonkeyEcxTokenStorageService {
3678
3697
  me$.next(previousMe);
3679
3698
  }
3680
3699
  getAllMe() {
3681
- const me = localStorage.getItem('me');
3682
- return JSON.parse(me || '{}');
3700
+ return __awaiter(this, void 0, void 0, function* () {
3701
+ const { store } = this;
3702
+ const username = localStorage.getItem('username');
3703
+ let data = {
3704
+ username: username || '',
3705
+ program: ''
3706
+ };
3707
+ if (username) {
3708
+ data = yield store.select(select({ username })).pipe(take(1)).toPromise();
3709
+ }
3710
+ return data === null || data === void 0 ? void 0 : data.me;
3711
+ });
3683
3712
  }
3684
3713
  tokenHasChanged() {
3685
3714
  return this.token$.asObservable();
@@ -3758,7 +3787,7 @@ class MonkeyEcxSecurityDirective {
3758
3787
  this.cdr = cdr;
3759
3788
  this.roles = [];
3760
3789
  this.byExclusion = false;
3761
- this.tokenCredentials = null;
3790
+ this.tokenCredentials = undefined;
3762
3791
  // not to do
3763
3792
  }
3764
3793
  getRole() {
@@ -3791,15 +3820,19 @@ class MonkeyEcxSecurityDirective {
3791
3820
  this.elementRef.nativeElement.style.display = display;
3792
3821
  this.cdr.detectChanges();
3793
3822
  }
3823
+ handleData() {
3824
+ return __awaiter(this, void 0, void 0, function* () {
3825
+ this.tokenCredentials = yield this.tokenStorageService.getToken();
3826
+ this.handleAccess();
3827
+ });
3828
+ }
3794
3829
  ngOnInit() {
3795
3830
  this.elementRef.nativeElement.style.display = 'none';
3796
3831
  this.cdr.detectChanges();
3797
3832
  this.tokenStorageService.tokenHasChanged().subscribe(() => {
3798
- this.tokenCredentials = this.tokenStorageService.getToken();
3799
- this.handleAccess();
3833
+ this.handleData();
3800
3834
  });
3801
- this.tokenCredentials = this.tokenStorageService.getToken();
3802
- this.handleAccess();
3835
+ this.handleData();
3803
3836
  }
3804
3837
  }
3805
3838
  MonkeyEcxSecurityDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxSecurityDirective, deps: [{ token: i0.ElementRef }, { token: MonkeyEcxTokenStorageService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
@@ -3807,7 +3840,7 @@ MonkeyEcxSecurityDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0
3807
3840
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxSecurityDirective, decorators: [{
3808
3841
  type: Directive,
3809
3842
  args: [{
3810
- selector: '[monkeyecxSecurity]',
3843
+ selector: '[monkeyecxSecurity]'
3811
3844
  }]
3812
3845
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MonkeyEcxTokenStorageService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { roles: [{
3813
3846
  type: Input,
@@ -3979,13 +4012,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
3979
4012
  }]
3980
4013
  }], ctorParameters: function () { return [{ type: i1.MonkeyStyleGuideSnackbarService }, { type: i1$1.TranslateService }]; } });
3981
4014
 
3982
- /* eslint-disable no-console */
3983
4015
  class MonkeyEcxAuthenticationService {
3984
4016
  constructor() {
3985
- this.hadAtLeastOneLogin = () => {
4017
+ this.hadAtLeastOneLogin = () => __awaiter(this, void 0, void 0, function* () {
3986
4018
  console.error('hadAtLeastOneLogin needs to be declared!');
3987
4019
  return null;
3988
- };
4020
+ });
3989
4021
  this.redirectApp = () => {
3990
4022
  console.error('redirectApp needs to be declared!');
3991
4023
  return null;
@@ -3994,14 +4026,14 @@ class MonkeyEcxAuthenticationService {
3994
4026
  console.error('redirectLoginWelcomeBack needs to be declared!');
3995
4027
  return null;
3996
4028
  };
3997
- this.isAuthorized = () => {
4029
+ this.isAuthorized = () => __awaiter(this, void 0, void 0, function* () {
3998
4030
  console.error('isAuthorized needs to be declared!');
3999
4031
  return false;
4000
- };
4001
- this.isCompanyAuthorized = () => {
4032
+ });
4033
+ this.isCompanyAuthorized = () => __awaiter(this, void 0, void 0, function* () {
4002
4034
  console.error('isCompanyAuthorized needs to be declared!');
4003
4035
  return false;
4004
- };
4036
+ });
4005
4037
  this.isTokenMandatory = (url) => {
4006
4038
  console.error('isTokenMandatory needs to be declared!');
4007
4039
  return false;
@@ -4014,6 +4046,10 @@ class MonkeyEcxAuthenticationService {
4014
4046
  console.error('getRequestWithHeadersOb needs to be declared!');
4015
4047
  return null;
4016
4048
  };
4049
+ this.getRequestWithHeadersAsync = (request) => __awaiter(this, void 0, void 0, function* () {
4050
+ console.error('getRequestWithHeadersAsync needs to be declared!');
4051
+ return null;
4052
+ });
4017
4053
  this.refreshShouldHappen = (response) => {
4018
4054
  console.error('refreshShouldHappen needs to be declared!');
4019
4055
  return false;
@@ -4034,6 +4070,8 @@ class MonkeyEcxAuthenticationService {
4034
4070
  this.isCompanyAuthorized = (args === null || args === void 0 ? void 0 : args.isCompanyAuthorized) || this.isCompanyAuthorized.bind(this);
4035
4071
  this.getRequestWithHeaders =
4036
4072
  (args === null || args === void 0 ? void 0 : args.getRequestWithHeaders) || this.getRequestWithHeaders.bind(this);
4073
+ this.getRequestWithHeadersAsync =
4074
+ (args === null || args === void 0 ? void 0 : args.getRequestWithHeadersAsync) || this.getRequestWithHeadersAsync.bind(this);
4037
4075
  this.getRequestWithHeadersOb = args === null || args === void 0 ? void 0 : args.getRequestWithHeadersOb.bind(this);
4038
4076
  this.refreshShouldHappen = (args === null || args === void 0 ? void 0 : args.refreshShouldHappen) || this.refreshShouldHappen.bind(this);
4039
4077
  this.refreshToken = (args === null || args === void 0 ? void 0 : args.refreshToken) || this.refreshToken.bind(this);
@@ -4052,16 +4090,18 @@ class MonkeyEcxAuthGuardCompany {
4052
4090
  // not to do
4053
4091
  }
4054
4092
  canActivate() {
4055
- const { monkeyecxAuthenticationService } = this;
4056
- if (this.monkeyecxAuthenticationService.isAuthorized()) {
4057
- if (monkeyecxAuthenticationService.isCompanyAuthorized()) {
4058
- return true;
4093
+ return __awaiter(this, void 0, void 0, function* () {
4094
+ const { monkeyecxAuthenticationService } = this;
4095
+ if (yield this.monkeyecxAuthenticationService.isAuthorized()) {
4096
+ if (yield monkeyecxAuthenticationService.isCompanyAuthorized()) {
4097
+ return true;
4098
+ }
4099
+ this.monkeyecxAuthenticationService.redirectApp();
4100
+ return false;
4059
4101
  }
4060
- this.monkeyecxAuthenticationService.redirectApp();
4102
+ monkeyecxAuthenticationService.redirectLoginWelcomeBack();
4061
4103
  return false;
4062
- }
4063
- monkeyecxAuthenticationService.redirectLoginWelcomeBack();
4064
- return false;
4104
+ });
4065
4105
  }
4066
4106
  }
4067
4107
  MonkeyEcxAuthGuardCompany.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxAuthGuardCompany, deps: [{ token: MonkeyEcxAuthenticationService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -4077,15 +4117,17 @@ class MonkeyEcxAuthGuardLogin {
4077
4117
  // not to do
4078
4118
  }
4079
4119
  canActivate() {
4080
- if (this.monkeyecxAuthenticationService.isAuthorized()) {
4081
- this.monkeyecxAuthenticationService.redirectApp();
4082
- return false;
4083
- }
4084
- if (this.monkeyecxAuthenticationService.hadAtLeastOneLogin()) {
4085
- this.monkeyecxAuthenticationService.redirectLoginWelcomeBack();
4086
- return false;
4087
- }
4088
- return true;
4120
+ return __awaiter(this, void 0, void 0, function* () {
4121
+ if (yield this.monkeyecxAuthenticationService.isAuthorized()) {
4122
+ this.monkeyecxAuthenticationService.redirectApp();
4123
+ return false;
4124
+ }
4125
+ if (yield this.monkeyecxAuthenticationService.hadAtLeastOneLogin()) {
4126
+ this.monkeyecxAuthenticationService.redirectLoginWelcomeBack();
4127
+ return false;
4128
+ }
4129
+ return true;
4130
+ });
4089
4131
  }
4090
4132
  }
4091
4133
  MonkeyEcxAuthGuardLogin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxAuthGuardLogin, deps: [{ token: MonkeyEcxAuthenticationService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -4101,12 +4143,14 @@ class MonkeyEcxAuthGuard {
4101
4143
  // not to do
4102
4144
  }
4103
4145
  canActivate() {
4104
- const { monkeyecxAuthenticationService } = this;
4105
- if (monkeyecxAuthenticationService.isAuthorized()) {
4106
- return true;
4107
- }
4108
- monkeyecxAuthenticationService.redirectLoginWelcomeBack();
4109
- return false;
4146
+ return __awaiter(this, void 0, void 0, function* () {
4147
+ const { monkeyecxAuthenticationService } = this;
4148
+ if (yield monkeyecxAuthenticationService.isAuthorized()) {
4149
+ return true;
4150
+ }
4151
+ monkeyecxAuthenticationService.redirectLoginWelcomeBack();
4152
+ return false;
4153
+ });
4110
4154
  }
4111
4155
  }
4112
4156
  MonkeyEcxAuthGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxAuthGuard, deps: [{ token: MonkeyEcxAuthenticationService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -4305,31 +4349,33 @@ class MonkeyEcxHttpErrorHandlingService extends MonkeyEcxCommonsService {
4305
4349
  }
4306
4350
  }
4307
4351
  handleError(error, mkc) {
4308
- const { router, tokenStorage } = this;
4309
- const { status } = error;
4310
- const { companyType } = (tokenStorage === null || tokenStorage === void 0 ? void 0 : tokenStorage.getToken()) || { companyType: '' };
4311
- const routes = {
4312
- 403: 'forbidden',
4313
- 500: 'service-problems',
4314
- 503: 'service-problems'
4315
- };
4316
- let route = '/app';
4317
- if (companyType) {
4318
- route = `${route}/${companyType}/pages`;
4319
- }
4320
- else {
4321
- route = `${route}/pages`;
4322
- }
4323
- const found = routes[status];
4324
- let timeout = 0;
4325
- if (found && !this.isHttpCodeIgnoreRedirect(mkc, error === null || error === void 0 ? void 0 : error.status)) {
4326
- route = `${route}/${found}`.toLowerCase();
4327
- timeout = 800;
4328
- router.navigate([route]);
4329
- }
4330
- setTimeout(() => {
4331
- this.handleMessage(error, mkc);
4332
- }, timeout);
4352
+ return __awaiter(this, void 0, void 0, function* () {
4353
+ const { router, tokenStorage } = this;
4354
+ const { status } = error;
4355
+ const { companyType } = (yield (tokenStorage === null || tokenStorage === void 0 ? void 0 : tokenStorage.getToken())) || { companyType: '' };
4356
+ const routes = {
4357
+ 403: 'forbidden',
4358
+ 500: 'service-problems',
4359
+ 503: 'service-problems'
4360
+ };
4361
+ let route = '/app';
4362
+ if (companyType) {
4363
+ route = `${route}/${companyType}/pages`;
4364
+ }
4365
+ else {
4366
+ route = `${route}/pages`;
4367
+ }
4368
+ const found = routes[status];
4369
+ let timeout = 0;
4370
+ if (found && !this.isHttpCodeIgnoreRedirect(mkc, error === null || error === void 0 ? void 0 : error.status)) {
4371
+ route = `${route}/${found}`.toLowerCase();
4372
+ timeout = 800;
4373
+ router.navigate([route]);
4374
+ }
4375
+ setTimeout(() => {
4376
+ this.handleMessage(error, mkc);
4377
+ }, timeout);
4378
+ });
4333
4379
  }
4334
4380
  handleErrorRefreshToken(error, mkc) {
4335
4381
  if (error.status === 401 || error.status === 400) {
@@ -5240,15 +5286,14 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
5240
5286
  // not to do
5241
5287
  }
5242
5288
  }
5243
- const resp = yield this.authService
5244
- .getRequestWithHeadersOb(request)
5245
- .pipe(take(1), map((event) => {
5246
- return event;
5247
- }), catchError((error) => {
5248
- this.errorHandlingService.handleError(error);
5249
- return throwError(error);
5250
- }))
5251
- .toPromise();
5289
+ let resp = null;
5290
+ try {
5291
+ resp = yield this.authService.getRequestWithHeadersAsync(request);
5292
+ }
5293
+ catch (e) {
5294
+ this.errorHandlingService.handleError(e);
5295
+ return throwError(e);
5296
+ }
5252
5297
  return resp;
5253
5298
  });
5254
5299
  }