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.
@@ -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 = undefined;
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
- 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;
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
- 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;
3677
+ catch (e) {
3678
+ console.log('=======');
3679
+ console.log(e);
3680
+ console.log('=======');
3673
3681
  }
3674
- return data;
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 = undefined;
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
- var _a, _b;
5243
- if (this.monkeyecxAuthenticationService.refreshShouldHappen(error)) {
5244
- return ((_b = (_a = this.monkeyecxAuthenticationService) === null || _a === void 0 ? void 0 : _a.refreshToken()) === null || _b === void 0 ? void 0 : _b.pipe(take(1), map(() => {
5245
- return this.monkeyecxAuthenticationService.getRequestWithHeaders(request);
5246
- }), mergeMap((resp) => {
5247
- return next.handle(resp).pipe(catchError((error) => {
5248
- this.monkeyecxErrorHandlingService.handleError(error, 'refresh_token');
5249
- return throwError(null);
5250
- }));
5251
- }), catchError((error) => {
5252
- this.monkeyecxErrorHandlingService.handleError(error, 'refresh_token');
5253
- return throwError(null);
5254
- }))) || throwError(error);
5255
- }
5256
- return throwError(error);
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
  });