@osovitny/anatoly 3.19.5 → 3.19.6

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.
@@ -2003,21 +2003,26 @@ class AuthService extends ApiServiceBase {
2003
2003
  }));
2004
2004
  }
2005
2005
  //2. if isUserAuthenticated
2006
- let activeAccount = this.getActiveAccount();
2007
- if (activeAccount) {
2008
- let silentRequest = {
2009
- scopes: MSALUtils.getApiScopes(),
2010
- account: activeAccount
2011
- };
2012
- return this.msalService.acquireTokenSilent(silentRequest).pipe(map$1(response => {
2013
- return response.accessToken;
2014
- }), catchError(error => {
2015
- console.log("Silent token acquisition fails.");
2016
- if (error instanceof InteractionRequiredAuthError) {
2017
- return this.acquireToken();
2018
- }
2019
- return of(null);
2020
- }));
2006
+ try {
2007
+ let activeAccount = this.getActiveAccount();
2008
+ if (activeAccount) {
2009
+ let silentRequest = {
2010
+ scopes: MSALUtils.getApiScopes(),
2011
+ account: activeAccount
2012
+ };
2013
+ return this.msalService.acquireTokenSilent(silentRequest).pipe(map$1(response => {
2014
+ return response.accessToken;
2015
+ }), catchError(error => {
2016
+ console.log("Silent token acquisition fails.");
2017
+ if (error instanceof InteractionRequiredAuthError) {
2018
+ return this.acquireToken();
2019
+ }
2020
+ return of(null);
2021
+ }));
2022
+ }
2023
+ }
2024
+ catch (error) {
2025
+ console.error("An error occurred: ", error);
2021
2026
  }
2022
2027
  return of(null);
2023
2028
  }
@@ -2475,8 +2480,8 @@ class AnatolyHttpInterceptor {
2475
2480
  }
2476
2481
  },
2477
2482
  error: (err) => {
2478
- this.onRequestEnd(loadingRequired);
2479
2483
  this.logger.error(err);
2484
+ this.onRequestEnd(loadingRequired);
2480
2485
  }
2481
2486
  }));
2482
2487
  }
@@ -2550,17 +2555,23 @@ class AnatolyHttpInterceptor {
2550
2555
  req = req.clone({ url: newUrl });
2551
2556
  req = req.clone({ headers: req.headers.set('Accept', 'application/json') });
2552
2557
  req = req.clone({ headers: req.headers.set('Accept', 'application/text') });
2553
- this.onRequestStart(loadingRequired);
2554
- if (authorizationTokenRequired) {
2555
- return this.authService.getAccessToken().pipe(mergeMap((token) => {
2556
- if (token) {
2557
- req = req.clone({ headers: req.headers.set('Authorization', 'Bearer ' + token) });
2558
- }
2558
+ try {
2559
+ this.onRequestStart(loadingRequired);
2560
+ if (authorizationTokenRequired) {
2561
+ return this.authService.getAccessToken().pipe(mergeMap((token) => {
2562
+ if (token) {
2563
+ req = req.clone({ headers: req.headers.set('Authorization', 'Bearer ' + token) });
2564
+ }
2565
+ return this.handleHttpRequest(req, next, loadingRequired);
2566
+ }));
2567
+ }
2568
+ else {
2559
2569
  return this.handleHttpRequest(req, next, loadingRequired);
2560
- }));
2570
+ }
2561
2571
  }
2562
- else {
2563
- return this.handleHttpRequest(req, next, loadingRequired);
2572
+ catch (err) {
2573
+ this.logger.error("An error occurred: " + err);
2574
+ this.onRequestEnd(loadingRequired);
2564
2575
  }
2565
2576
  }
2566
2577
  //Events