monkey-front-core 0.0.196 → 0.0.199
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/interceptors/monkeyecx-http-config-header.interceptor.mjs +34 -12
- package/esm2020/lib/core/services/auth/monkeyecx-authentication.service.mjs +6 -1
- package/fesm2015/monkey-front-core.mjs +46 -19
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +36 -10
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/interceptors/monkeyecx-http-config-header.interceptor.d.ts +6 -3
- package/lib/core/services/auth/monkeyecx-authentication.service.d.ts +4 -2
- package/monkey-front-core-0.0.199.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.196.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';
|
|
@@ -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);
|
|
@@ -4670,13 +4675,30 @@ 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
|
+
await this.config
|
|
4689
|
+
.config()
|
|
4690
|
+
.pipe(first((val) => {
|
|
4691
|
+
return !!val;
|
|
4692
|
+
}))
|
|
4693
|
+
.toPromise();
|
|
4694
|
+
}
|
|
4695
|
+
catch (e) {
|
|
4696
|
+
// not to do
|
|
4697
|
+
}
|
|
4698
|
+
}
|
|
4699
|
+
return this.authService
|
|
4700
|
+
.getRequestWithHeadersOb(request)
|
|
4701
|
+
.pipe(take(1), map((event) => {
|
|
4680
4702
|
return event;
|
|
4681
4703
|
}), mergeMap((resp) => {
|
|
4682
4704
|
request = request.clone({
|
|
@@ -4684,16 +4706,20 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
|
4684
4706
|
});
|
|
4685
4707
|
return next.handle(request);
|
|
4686
4708
|
}), catchError((error) => {
|
|
4687
|
-
this.
|
|
4709
|
+
this.errorHandlingService.handleError(error);
|
|
4688
4710
|
return throwError(error);
|
|
4689
|
-
}))
|
|
4711
|
+
}))
|
|
4712
|
+
.toPromise();
|
|
4713
|
+
}
|
|
4714
|
+
intercept(request, next) {
|
|
4715
|
+
return from(this.handle(request, next));
|
|
4690
4716
|
}
|
|
4691
4717
|
}
|
|
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 });
|
|
4718
|
+
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
4719
|
MonkeyEcxHttpConfigHeaderInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor });
|
|
4694
4720
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor, decorators: [{
|
|
4695
4721
|
type: Injectable
|
|
4696
|
-
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: MonkeyEcxErrorHandlingService }]; } });
|
|
4722
|
+
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: MonkeyEcxErrorHandlingService }, { type: MonkeyEcxConfigService }]; } });
|
|
4697
4723
|
|
|
4698
4724
|
/* eslint-disable max-len */
|
|
4699
4725
|
class MonkeyEcxHttpConfigQueueInterceptor {
|