monkey-front-core 0.0.195 → 0.0.198
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.
- package/esm2020/lib/core/directives/monkeyecx-feature-by-program-directive.mjs +2 -2
- package/esm2020/lib/core/interceptors/monkeyecx-http-config-header.interceptor.mjs +54 -11
- package/esm2020/lib/core/services/auth/monkeyecx-authentication.service.mjs +6 -1
- package/esm2020/lib/core/services/commons/monkeyecx-commons.service.mjs +3 -3
- package/fesm2015/monkey-front-core.mjs +74 -26
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +60 -13
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/interceptors/monkeyecx-http-config-header.interceptor.d.ts +7 -3
- package/lib/core/services/auth/monkeyecx-authentication.service.d.ts +4 -2
- package/monkey-front-core-0.0.198.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.195.tgz +0 -0
|
@@ -10,7 +10,7 @@ import * as moment_ from 'moment';
|
|
|
10
10
|
import * as i1$2 from 'ngx-cookie-service';
|
|
11
11
|
import * as i1$3 from '@angular/router';
|
|
12
12
|
import { NavigationStart, NavigationEnd, NavigationError, NavigationCancel } from '@angular/router';
|
|
13
|
-
import { BehaviorSubject, Subscription, throwError, interval, concat, of, Subject } from 'rxjs';
|
|
13
|
+
import { BehaviorSubject, Subscription, throwError, interval, concat, of, Subject, from } from 'rxjs';
|
|
14
14
|
import { filter, take, takeWhile, map, catchError, first, takeUntil, mergeMap, finalize } from 'rxjs/operators';
|
|
15
15
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
16
16
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
@@ -2220,8 +2220,8 @@ class MonkeyEcxCommonsService {
|
|
|
2220
2220
|
const { config, feature } = args;
|
|
2221
2221
|
try {
|
|
2222
2222
|
if (!MonkeyEcxUtils.persistNullEmptyUndefined(feature) ||
|
|
2223
|
-
!MonkeyEcxUtils.persistNullEmptyUndefined(config?.program?.settings
|
|
2224
|
-
return
|
|
2223
|
+
!MonkeyEcxUtils.persistNullEmptyUndefined(config?.program?.settings)) {
|
|
2224
|
+
return true;
|
|
2225
2225
|
}
|
|
2226
2226
|
return !config?.program?.settings?.[feature];
|
|
2227
2227
|
}
|
|
@@ -3467,6 +3467,10 @@ class MonkeyEcxAuthenticationService {
|
|
|
3467
3467
|
console.error('isCompanyAuthorized needs to be declared!');
|
|
3468
3468
|
return false;
|
|
3469
3469
|
};
|
|
3470
|
+
this.isTokenMandatory = (url) => {
|
|
3471
|
+
console.error('isTokenMandatory needs to be declared!');
|
|
3472
|
+
return false;
|
|
3473
|
+
};
|
|
3470
3474
|
this.getRequestWithHeaders = (request) => {
|
|
3471
3475
|
console.error('getRequestWithHeaders needs to be declared!');
|
|
3472
3476
|
return null;
|
|
@@ -3491,6 +3495,7 @@ class MonkeyEcxAuthenticationService {
|
|
|
3491
3495
|
this.redirectLoginWelcomeBack =
|
|
3492
3496
|
args?.redirectLoginWelcomeBack || this.redirectLoginWelcomeBack.bind(this);
|
|
3493
3497
|
this.isAuthorized = args?.isAuthorized || this.isAuthorized.bind(this);
|
|
3498
|
+
this.isTokenMandatory = args?.isTokenMandatory || this.isTokenMandatory.bind(this);
|
|
3494
3499
|
this.isCompanyAuthorized = args?.isCompanyAuthorized || this.isCompanyAuthorized.bind(this);
|
|
3495
3500
|
this.getRequestWithHeaders =
|
|
3496
3501
|
args?.getRequestWithHeaders || this.getRequestWithHeaders.bind(this);
|
|
@@ -4483,7 +4488,7 @@ class MonkeyEcxFeatureByProgramDirective {
|
|
|
4483
4488
|
const { feature, config } = this;
|
|
4484
4489
|
let display = 'none';
|
|
4485
4490
|
if (!MonkeyEcxUtils.persistNullEmptyUndefined(feature) ||
|
|
4486
|
-
!MonkeyEcxUtils.persistNullEmptyUndefined(config?.program?.settings
|
|
4491
|
+
!MonkeyEcxUtils.persistNullEmptyUndefined(config?.program?.settings)) {
|
|
4487
4492
|
return;
|
|
4488
4493
|
}
|
|
4489
4494
|
const disabled = config?.program?.settings?.[feature];
|
|
@@ -4670,13 +4675,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
4670
4675
|
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: MonkeyEcxErrorHandlingService }]; } });
|
|
4671
4676
|
|
|
4672
4677
|
class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
4673
|
-
constructor(
|
|
4674
|
-
this.
|
|
4675
|
-
this.
|
|
4678
|
+
constructor(authService, errorHandlingService, config) {
|
|
4679
|
+
this.authService = authService;
|
|
4680
|
+
this.errorHandlingService = errorHandlingService;
|
|
4681
|
+
this.config = config;
|
|
4676
4682
|
// not to do
|
|
4677
4683
|
}
|
|
4678
|
-
|
|
4679
|
-
|
|
4684
|
+
async handle(request, next) {
|
|
4685
|
+
const { url } = request;
|
|
4686
|
+
if (this.authService.isTokenMandatory(url)) {
|
|
4687
|
+
try {
|
|
4688
|
+
const config = await this.config
|
|
4689
|
+
.config()
|
|
4690
|
+
.pipe(take(1))
|
|
4691
|
+
.toPromise();
|
|
4692
|
+
if (!config) {
|
|
4693
|
+
await this.onValidateConfig();
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
catch (error) {
|
|
4697
|
+
// not to do
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
return this.authService
|
|
4701
|
+
.getRequestWithHeadersOb(request)
|
|
4702
|
+
.pipe(take(1), map((event) => {
|
|
4680
4703
|
return event;
|
|
4681
4704
|
}), mergeMap((resp) => {
|
|
4682
4705
|
request = request.clone({
|
|
@@ -4684,16 +4707,40 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
|
4684
4707
|
});
|
|
4685
4708
|
return next.handle(request);
|
|
4686
4709
|
}), catchError((error) => {
|
|
4687
|
-
this.
|
|
4710
|
+
this.errorHandlingService.handleError(error);
|
|
4688
4711
|
return throwError(error);
|
|
4689
|
-
}))
|
|
4712
|
+
}))
|
|
4713
|
+
.toPromise();
|
|
4714
|
+
}
|
|
4715
|
+
onValidateConfig() {
|
|
4716
|
+
return new Promise((resolve) => {
|
|
4717
|
+
let count = 0;
|
|
4718
|
+
const interval = setInterval(async () => {
|
|
4719
|
+
count += 1;
|
|
4720
|
+
if (count > 20) {
|
|
4721
|
+
clearInterval(interval);
|
|
4722
|
+
resolve(null);
|
|
4723
|
+
}
|
|
4724
|
+
const config = await this.config
|
|
4725
|
+
.config()
|
|
4726
|
+
.pipe(take(1))
|
|
4727
|
+
.toPromise();
|
|
4728
|
+
if (config) {
|
|
4729
|
+
clearInterval(interval);
|
|
4730
|
+
resolve(null);
|
|
4731
|
+
}
|
|
4732
|
+
}, 200);
|
|
4733
|
+
});
|
|
4734
|
+
}
|
|
4735
|
+
intercept(request, next) {
|
|
4736
|
+
return from(this.handle(request, next));
|
|
4690
4737
|
}
|
|
4691
4738
|
}
|
|
4692
|
-
MonkeyEcxHttpConfigHeaderInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor, deps: [{ token: MonkeyEcxAuthenticationService }, { token: MonkeyEcxErrorHandlingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4739
|
+
MonkeyEcxHttpConfigHeaderInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor, deps: [{ token: MonkeyEcxAuthenticationService }, { token: MonkeyEcxErrorHandlingService }, { token: MonkeyEcxConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4693
4740
|
MonkeyEcxHttpConfigHeaderInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor });
|
|
4694
4741
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor, decorators: [{
|
|
4695
4742
|
type: Injectable
|
|
4696
|
-
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: MonkeyEcxErrorHandlingService }]; } });
|
|
4743
|
+
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: MonkeyEcxErrorHandlingService }, { type: MonkeyEcxConfigService }]; } });
|
|
4697
4744
|
|
|
4698
4745
|
/* eslint-disable max-len */
|
|
4699
4746
|
class MonkeyEcxHttpConfigQueueInterceptor {
|