monkey-front-core 0.0.305 → 0.0.307
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-error.interceptor.mjs +35 -16
- package/esm2020/lib/core/interceptors/monkeyecx-http-config-header.interceptor.mjs +20 -10
- package/esm2020/lib/core/services/auth/monkeyecx-auth-guard-company.service.mjs +4 -4
- package/esm2020/lib/core/services/auth/monkeyecx-auth-guard-login.service.mjs +4 -4
- package/esm2020/lib/core/services/auth/monkeyecx-auth-guard.service.mjs +3 -3
- package/esm2020/lib/core/services/auth/monkeyecx-authentication.service.mjs +11 -6
- package/fesm2015/monkey-front-core.mjs +98 -56
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +70 -36
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/interceptors/monkeyecx-http-config-error.interceptor.d.ts +1 -0
- package/lib/core/interceptors/monkeyecx-http-config-header.interceptor.d.ts +2 -2
- package/lib/core/services/auth/monkeyecx-auth-guard-company.service.d.ts +1 -2
- package/lib/core/services/auth/monkeyecx-auth-guard-login.service.d.ts +1 -2
- package/lib/core/services/auth/monkeyecx-auth-guard.service.d.ts +1 -2
- package/lib/core/services/auth/monkeyecx-authentication.service.d.ts +7 -5
- package/monkey-front-core-0.0.307.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.305.tgz +0 -0
|
@@ -4015,10 +4015,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
4015
4015
|
}]
|
|
4016
4016
|
}], ctorParameters: function () { return [{ type: i1.MonkeyStyleGuideSnackbarService }, { type: i1$1.TranslateService }]; } });
|
|
4017
4017
|
|
|
4018
|
-
/* eslint-disable no-console */
|
|
4019
4018
|
class MonkeyEcxAuthenticationService {
|
|
4020
4019
|
constructor() {
|
|
4021
|
-
this.hadAtLeastOneLogin = () => {
|
|
4020
|
+
this.hadAtLeastOneLogin = async () => {
|
|
4022
4021
|
console.error('hadAtLeastOneLogin needs to be declared!');
|
|
4023
4022
|
return null;
|
|
4024
4023
|
};
|
|
@@ -4030,11 +4029,11 @@ class MonkeyEcxAuthenticationService {
|
|
|
4030
4029
|
console.error('redirectLoginWelcomeBack needs to be declared!');
|
|
4031
4030
|
return null;
|
|
4032
4031
|
};
|
|
4033
|
-
this.isAuthorized = () => {
|
|
4032
|
+
this.isAuthorized = async () => {
|
|
4034
4033
|
console.error('isAuthorized needs to be declared!');
|
|
4035
4034
|
return false;
|
|
4036
4035
|
};
|
|
4037
|
-
this.isCompanyAuthorized = () => {
|
|
4036
|
+
this.isCompanyAuthorized = async () => {
|
|
4038
4037
|
console.error('isCompanyAuthorized needs to be declared!');
|
|
4039
4038
|
return false;
|
|
4040
4039
|
};
|
|
@@ -4050,11 +4049,15 @@ class MonkeyEcxAuthenticationService {
|
|
|
4050
4049
|
console.error('getRequestWithHeadersOb needs to be declared!');
|
|
4051
4050
|
return null;
|
|
4052
4051
|
};
|
|
4052
|
+
this.getRequestWithHeadersAsync = async (request) => {
|
|
4053
|
+
console.error('getRequestWithHeadersAsync needs to be declared!');
|
|
4054
|
+
return null;
|
|
4055
|
+
};
|
|
4053
4056
|
this.refreshShouldHappen = (response) => {
|
|
4054
4057
|
console.error('refreshShouldHappen needs to be declared!');
|
|
4055
4058
|
return false;
|
|
4056
4059
|
};
|
|
4057
|
-
this.refreshToken = () => {
|
|
4060
|
+
this.refreshToken = async () => {
|
|
4058
4061
|
console.error('refreshToken needs to be declared!');
|
|
4059
4062
|
return null;
|
|
4060
4063
|
};
|
|
@@ -4070,6 +4073,8 @@ class MonkeyEcxAuthenticationService {
|
|
|
4070
4073
|
this.isCompanyAuthorized = args?.isCompanyAuthorized || this.isCompanyAuthorized.bind(this);
|
|
4071
4074
|
this.getRequestWithHeaders =
|
|
4072
4075
|
args?.getRequestWithHeaders || this.getRequestWithHeaders.bind(this);
|
|
4076
|
+
this.getRequestWithHeadersAsync =
|
|
4077
|
+
args?.getRequestWithHeadersAsync || this.getRequestWithHeadersAsync.bind(this);
|
|
4073
4078
|
this.getRequestWithHeadersOb = args?.getRequestWithHeadersOb.bind(this);
|
|
4074
4079
|
this.refreshShouldHappen = args?.refreshShouldHappen || this.refreshShouldHappen.bind(this);
|
|
4075
4080
|
this.refreshToken = args?.refreshToken || this.refreshToken.bind(this);
|
|
@@ -4087,10 +4092,10 @@ class MonkeyEcxAuthGuardCompany {
|
|
|
4087
4092
|
this.monkeyecxAuthenticationService = monkeyecxAuthenticationService;
|
|
4088
4093
|
// not to do
|
|
4089
4094
|
}
|
|
4090
|
-
canActivate() {
|
|
4095
|
+
async canActivate() {
|
|
4091
4096
|
const { monkeyecxAuthenticationService } = this;
|
|
4092
|
-
if (this.monkeyecxAuthenticationService.isAuthorized()) {
|
|
4093
|
-
if (monkeyecxAuthenticationService.isCompanyAuthorized()) {
|
|
4097
|
+
if (await this.monkeyecxAuthenticationService.isAuthorized()) {
|
|
4098
|
+
if (await monkeyecxAuthenticationService.isCompanyAuthorized()) {
|
|
4094
4099
|
return true;
|
|
4095
4100
|
}
|
|
4096
4101
|
this.monkeyecxAuthenticationService.redirectApp();
|
|
@@ -4112,12 +4117,12 @@ class MonkeyEcxAuthGuardLogin {
|
|
|
4112
4117
|
this.monkeyecxAuthenticationService = monkeyecxAuthenticationService;
|
|
4113
4118
|
// not to do
|
|
4114
4119
|
}
|
|
4115
|
-
canActivate() {
|
|
4116
|
-
if (this.monkeyecxAuthenticationService.isAuthorized()) {
|
|
4120
|
+
async canActivate() {
|
|
4121
|
+
if (await this.monkeyecxAuthenticationService.isAuthorized()) {
|
|
4117
4122
|
this.monkeyecxAuthenticationService.redirectApp();
|
|
4118
4123
|
return false;
|
|
4119
4124
|
}
|
|
4120
|
-
if (this.monkeyecxAuthenticationService.hadAtLeastOneLogin()) {
|
|
4125
|
+
if (await this.monkeyecxAuthenticationService.hadAtLeastOneLogin()) {
|
|
4121
4126
|
this.monkeyecxAuthenticationService.redirectLoginWelcomeBack();
|
|
4122
4127
|
return false;
|
|
4123
4128
|
}
|
|
@@ -4136,9 +4141,9 @@ class MonkeyEcxAuthGuard {
|
|
|
4136
4141
|
this.monkeyecxAuthenticationService = monkeyecxAuthenticationService;
|
|
4137
4142
|
// not to do
|
|
4138
4143
|
}
|
|
4139
|
-
canActivate() {
|
|
4144
|
+
async canActivate() {
|
|
4140
4145
|
const { monkeyecxAuthenticationService } = this;
|
|
4141
|
-
if (monkeyecxAuthenticationService.isAuthorized()) {
|
|
4146
|
+
if (await monkeyecxAuthenticationService.isAuthorized()) {
|
|
4142
4147
|
return true;
|
|
4143
4148
|
}
|
|
4144
4149
|
monkeyecxAuthenticationService.redirectLoginWelcomeBack();
|
|
@@ -5298,24 +5303,43 @@ class MonkeyEcxHttpConfigErrorInterceptor {
|
|
|
5298
5303
|
this.monkeyecxErrorHandlingService = monkeyecxErrorHandlingService;
|
|
5299
5304
|
// no to do
|
|
5300
5305
|
}
|
|
5306
|
+
async handle(request, error) {
|
|
5307
|
+
console.log('== interceptor error 4');
|
|
5308
|
+
console.log(request.url);
|
|
5309
|
+
if (this.monkeyecxAuthenticationService.refreshShouldHappen(error)) {
|
|
5310
|
+
console.log('== interceptor error 5');
|
|
5311
|
+
await this.monkeyecxAuthenticationService?.refreshToken();
|
|
5312
|
+
console.log('== interceptor error 6');
|
|
5313
|
+
const headers = await this.monkeyecxAuthenticationService.getRequestWithHeadersAsync(request);
|
|
5314
|
+
console.log('== interceptor error 7');
|
|
5315
|
+
console.log('headers');
|
|
5316
|
+
console.log(headers);
|
|
5317
|
+
return headers;
|
|
5318
|
+
}
|
|
5319
|
+
return throwError(error);
|
|
5320
|
+
}
|
|
5301
5321
|
intercept(request, next) {
|
|
5322
|
+
console.log('== interceptor error 1');
|
|
5302
5323
|
return next.handle(request).pipe(map((event) => {
|
|
5324
|
+
console.log('== interceptor error 2');
|
|
5303
5325
|
return event;
|
|
5304
5326
|
}), catchError((error) => {
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
})
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5327
|
+
console.log('== interceptor error 3');
|
|
5328
|
+
return from(this.handle(request, error)).pipe(take(1), map((event) => {
|
|
5329
|
+
return event;
|
|
5330
|
+
}), mergeMap((resp) => {
|
|
5331
|
+
console.log('== interceptor error 8');
|
|
5332
|
+
console.log(resp);
|
|
5333
|
+
request = request.clone({
|
|
5334
|
+
setHeaders: resp
|
|
5335
|
+
});
|
|
5336
|
+
return next.handle(request);
|
|
5337
|
+
}), catchError((error) => {
|
|
5338
|
+
console.log('== interceptor error 9');
|
|
5339
|
+
console.log(error);
|
|
5340
|
+
this.monkeyecxErrorHandlingService.handleError(error, 'refresh_token');
|
|
5341
|
+
return throwError(error);
|
|
5342
|
+
}));
|
|
5319
5343
|
}));
|
|
5320
5344
|
}
|
|
5321
5345
|
}
|
|
@@ -5334,6 +5358,8 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
|
5334
5358
|
}
|
|
5335
5359
|
async handle(request) {
|
|
5336
5360
|
const { url } = request;
|
|
5361
|
+
console.log('== interceptor header 2');
|
|
5362
|
+
console.log(url);
|
|
5337
5363
|
if (this.authService.isTokenMandatory(url)) {
|
|
5338
5364
|
try {
|
|
5339
5365
|
await this.config
|
|
@@ -5347,21 +5373,29 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
|
5347
5373
|
// not to do
|
|
5348
5374
|
}
|
|
5349
5375
|
}
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
}
|
|
5358
|
-
|
|
5376
|
+
console.log('== interceptor header 3');
|
|
5377
|
+
let resp = null;
|
|
5378
|
+
try {
|
|
5379
|
+
console.log('== interceptor header 4');
|
|
5380
|
+
resp = await this.authService.getRequestWithHeadersAsync(request);
|
|
5381
|
+
console.log('resp');
|
|
5382
|
+
console.log(resp);
|
|
5383
|
+
}
|
|
5384
|
+
catch (e) {
|
|
5385
|
+
console.log('== interceptor header 5');
|
|
5386
|
+
console.log(e);
|
|
5387
|
+
this.errorHandlingService.handleError(e);
|
|
5388
|
+
return throwError(e);
|
|
5389
|
+
}
|
|
5359
5390
|
return resp;
|
|
5360
5391
|
}
|
|
5361
5392
|
intercept(request, next) {
|
|
5393
|
+
console.log('== interceptor header 1');
|
|
5362
5394
|
return from(this.handle(request)).pipe(take(1), map((event) => {
|
|
5363
5395
|
return event;
|
|
5364
5396
|
}), mergeMap((resp) => {
|
|
5397
|
+
console.log('== interceptor header 6');
|
|
5398
|
+
console.log(resp);
|
|
5365
5399
|
request = request.clone({
|
|
5366
5400
|
setHeaders: resp
|
|
5367
5401
|
});
|