monkey-front-core 0.0.306 → 0.0.308
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-security-directive.mjs +2 -2
- package/esm2020/lib/core/interceptors/monkeyecx-http-config-error.interceptor.mjs +35 -16
- package/esm2020/lib/core/interceptors/monkeyecx-http-config-header.interceptor.mjs +12 -1
- package/esm2020/lib/core/services/auth/monkeyecx-authentication.service.mjs +2 -2
- package/esm2020/lib/core/services/commons/monkeyecx-commons.service.mjs +2 -2
- package/esm2020/lib/core/services/storage/monkeyecx-token-storage.service.mjs +26 -18
- package/fesm2015/monkey-front-core.mjs +76 -36
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +72 -34
- 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/services/auth/monkeyecx-authentication.service.d.ts +1 -1
- package/lib/core/services/commons/monkeyecx-commons.service.d.ts +2 -2
- package/lib/core/services/storage/monkeyecx-token-storage.service.d.ts +1 -1
- package/monkey-front-core-0.0.308.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.306.tgz +0 -0
|
@@ -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 =
|
|
2686
|
+
this.__tokenCredentials = null;
|
|
2687
2687
|
this.__schedule = null;
|
|
2688
2688
|
this.__callbackPagination = () => {
|
|
2689
2689
|
// eslint-disable-next-line no-console
|
|
@@ -3653,25 +3653,33 @@ class MonkeyEcxTokenStorageService {
|
|
|
3653
3653
|
getAllTokens() {
|
|
3654
3654
|
var _a;
|
|
3655
3655
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3656
|
+
try {
|
|
3657
|
+
const { store, monkeyecxConfigService } = this;
|
|
3658
|
+
const username = localStorage.getItem('username');
|
|
3659
|
+
let data = {
|
|
3660
|
+
username: username || '',
|
|
3661
|
+
program: ''
|
|
3662
|
+
};
|
|
3663
|
+
if (username) {
|
|
3664
|
+
data = yield store.select(select({ username })).pipe(take(1)).toPromise();
|
|
3665
|
+
data === null || data === void 0 ? true : delete data.me;
|
|
3666
|
+
}
|
|
3667
|
+
const config = yield monkeyecxConfigService.config()
|
|
3668
|
+
.pipe(first((val) => {
|
|
3669
|
+
return !!val && JSON.stringify(val) !== '{}';
|
|
3670
|
+
}))
|
|
3671
|
+
.toPromise();
|
|
3672
|
+
if (data && !(data === null || data === void 0 ? void 0 : data.program) && (config === null || config === void 0 ? void 0 : config.program)) {
|
|
3673
|
+
data.program = (_a = config === null || config === void 0 ? void 0 : config.program) === null || _a === void 0 ? void 0 : _a.token;
|
|
3674
|
+
}
|
|
3675
|
+
return data;
|
|
3665
3676
|
}
|
|
3666
|
-
|
|
3667
|
-
.
|
|
3668
|
-
|
|
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;
|
|
3677
|
+
catch (e) {
|
|
3678
|
+
console.log('=======');
|
|
3679
|
+
console.log(e);
|
|
3680
|
+
console.log('=======');
|
|
3673
3681
|
}
|
|
3674
|
-
return
|
|
3682
|
+
return null;
|
|
3675
3683
|
});
|
|
3676
3684
|
}
|
|
3677
3685
|
setAllMe(me) {
|
|
@@ -3787,7 +3795,7 @@ class MonkeyEcxSecurityDirective {
|
|
|
3787
3795
|
this.cdr = cdr;
|
|
3788
3796
|
this.roles = [];
|
|
3789
3797
|
this.byExclusion = false;
|
|
3790
|
-
this.tokenCredentials =
|
|
3798
|
+
this.tokenCredentials = null;
|
|
3791
3799
|
// not to do
|
|
3792
3800
|
}
|
|
3793
3801
|
getRole() {
|
|
@@ -4054,10 +4062,10 @@ class MonkeyEcxAuthenticationService {
|
|
|
4054
4062
|
console.error('refreshShouldHappen needs to be declared!');
|
|
4055
4063
|
return false;
|
|
4056
4064
|
};
|
|
4057
|
-
this.refreshToken = () => {
|
|
4065
|
+
this.refreshToken = () => __awaiter(this, void 0, void 0, function* () {
|
|
4058
4066
|
console.error('refreshToken needs to be declared!');
|
|
4059
4067
|
return null;
|
|
4060
|
-
};
|
|
4068
|
+
});
|
|
4061
4069
|
// not to do
|
|
4062
4070
|
}
|
|
4063
4071
|
init(args) {
|
|
@@ -5235,25 +5243,46 @@ class MonkeyEcxHttpConfigErrorInterceptor {
|
|
|
5235
5243
|
this.monkeyecxErrorHandlingService = monkeyecxErrorHandlingService;
|
|
5236
5244
|
// no to do
|
|
5237
5245
|
}
|
|
5246
|
+
handle(request, error) {
|
|
5247
|
+
var _a;
|
|
5248
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5249
|
+
console.log('== interceptor error 4');
|
|
5250
|
+
console.log(request.url);
|
|
5251
|
+
if (this.monkeyecxAuthenticationService.refreshShouldHappen(error)) {
|
|
5252
|
+
console.log('== interceptor error 5');
|
|
5253
|
+
yield ((_a = this.monkeyecxAuthenticationService) === null || _a === void 0 ? void 0 : _a.refreshToken());
|
|
5254
|
+
console.log('== interceptor error 6');
|
|
5255
|
+
const headers = yield this.monkeyecxAuthenticationService.getRequestWithHeadersAsync(request);
|
|
5256
|
+
console.log('== interceptor error 7');
|
|
5257
|
+
console.log('headers');
|
|
5258
|
+
console.log(headers);
|
|
5259
|
+
return headers;
|
|
5260
|
+
}
|
|
5261
|
+
return throwError(error);
|
|
5262
|
+
});
|
|
5263
|
+
}
|
|
5238
5264
|
intercept(request, next) {
|
|
5265
|
+
console.log('== interceptor error 1');
|
|
5239
5266
|
return next.handle(request).pipe(map((event) => {
|
|
5267
|
+
console.log('== interceptor error 2');
|
|
5240
5268
|
return event;
|
|
5241
5269
|
}), catchError((error) => {
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
return
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5270
|
+
console.log('== interceptor error 3');
|
|
5271
|
+
return from(this.handle(request, error)).pipe(take(1), map((event) => {
|
|
5272
|
+
return event;
|
|
5273
|
+
}), mergeMap((resp) => {
|
|
5274
|
+
console.log('== interceptor error 8');
|
|
5275
|
+
console.log(resp);
|
|
5276
|
+
request = request.clone({
|
|
5277
|
+
setHeaders: resp
|
|
5278
|
+
});
|
|
5279
|
+
return next.handle(request);
|
|
5280
|
+
}), catchError((error) => {
|
|
5281
|
+
console.log('== interceptor error 9');
|
|
5282
|
+
console.log(error);
|
|
5283
|
+
this.monkeyecxErrorHandlingService.handleError(error, 'refresh_token');
|
|
5284
|
+
return throwError(error);
|
|
5285
|
+
}));
|
|
5257
5286
|
}));
|
|
5258
5287
|
}
|
|
5259
5288
|
}
|
|
@@ -5273,6 +5302,8 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
|
5273
5302
|
handle(request) {
|
|
5274
5303
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5275
5304
|
const { url } = request;
|
|
5305
|
+
console.log('== interceptor header 2');
|
|
5306
|
+
console.log(url);
|
|
5276
5307
|
if (this.authService.isTokenMandatory(url)) {
|
|
5277
5308
|
try {
|
|
5278
5309
|
yield this.config
|
|
@@ -5286,11 +5317,17 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
|
5286
5317
|
// not to do
|
|
5287
5318
|
}
|
|
5288
5319
|
}
|
|
5320
|
+
console.log('== interceptor header 3');
|
|
5289
5321
|
let resp = null;
|
|
5290
5322
|
try {
|
|
5323
|
+
console.log('== interceptor header 4');
|
|
5291
5324
|
resp = yield this.authService.getRequestWithHeadersAsync(request);
|
|
5325
|
+
console.log('resp');
|
|
5326
|
+
console.log(resp);
|
|
5292
5327
|
}
|
|
5293
5328
|
catch (e) {
|
|
5329
|
+
console.log('== interceptor header 5');
|
|
5330
|
+
console.log(e);
|
|
5294
5331
|
this.errorHandlingService.handleError(e);
|
|
5295
5332
|
return throwError(e);
|
|
5296
5333
|
}
|
|
@@ -5298,9 +5335,12 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
|
5298
5335
|
});
|
|
5299
5336
|
}
|
|
5300
5337
|
intercept(request, next) {
|
|
5338
|
+
console.log('== interceptor header 1');
|
|
5301
5339
|
return from(this.handle(request)).pipe(take(1), map((event) => {
|
|
5302
5340
|
return event;
|
|
5303
5341
|
}), mergeMap((resp) => {
|
|
5342
|
+
console.log('== interceptor header 6');
|
|
5343
|
+
console.log(resp);
|
|
5304
5344
|
request = request.clone({
|
|
5305
5345
|
setHeaders: resp
|
|
5306
5346
|
});
|