@dereekb/dbx-core 9.5.4 → 9.6.1

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.
@@ -1691,7 +1691,7 @@ class DbxAuthService {
1691
1691
  * This generates a TransitionHookFn that can be used with redirecting routes.
1692
1692
  */
1693
1693
  function makeAuthTransitionHook(config) {
1694
- const { defaultRedirectTarget, errorRedirectTarget = defaultRedirectTarget } = config;
1694
+ const { defaultRedirectTarget, errorRedirectTarget = defaultRedirectTarget, timeoutTime = 1000 } = config;
1695
1695
  // https://ui-router.github.io/ng2/docs/latest/modules/transition.html#hookresult
1696
1696
  const assertIsAuthenticated = (transition) => {
1697
1697
  const injector = transition.injector();
@@ -1730,8 +1730,8 @@ function makeAuthTransitionHook(config) {
1730
1730
  return redirectToObs;
1731
1731
  }
1732
1732
  const resultObs = decisionObs.pipe(
1733
- // after 10 seconds of no transition working, redirect with a false decision
1734
- timeoutStartWith(false, 10 * 1000), first(), switchMap((decision) => {
1733
+ // after the timeoutTime seconds of no transition working, redirect with a false decision
1734
+ timeoutStartWith(false, timeoutTime), first(), switchMap((decision) => {
1735
1735
  if (typeof decision === 'boolean') {
1736
1736
  if (decision) {
1737
1737
  return of(true);
@@ -1745,7 +1745,7 @@ function makeAuthTransitionHook(config) {
1745
1745
  return of($state.target(asSegueRefString(segueRef.ref), segueRef.refParams, segueRef.refOptions));
1746
1746
  }
1747
1747
  }), catchError((x) => {
1748
- console.warn('Encountered error in auth transition hook.', x);
1748
+ console.warn(`Encountered error in auth transition hook. Attempting redirect to ${errorRedirectTarget}.`, x);
1749
1749
  return of($state.target(errorRedirectTarget, { location: true })); // Redirect to home
1750
1750
  }));
1751
1751
  return firstValueFrom(resultObs);
@@ -2482,7 +2482,7 @@ function isLatestSuccessfulRoute(config) {
2482
2482
  const { dbxRouterTransitionService, dbxRouterService, activeExactly } = config;
2483
2483
  const routes = asArray(config.routes);
2484
2484
  const checkRoute = activeExactly ? (route) => dbxRouterService.isActiveExactly(route) : (route) => dbxRouterService.isActive(route);
2485
- return successTransition(dbxRouterTransitionService.transitions$).pipe(map(() => {
2485
+ return successTransition(dbxRouterTransitionService.transitions$).pipe(startWith(undefined), map(() => {
2486
2486
  const isActive = routes.findIndex(checkRoute) !== -1;
2487
2487
  return isActive;
2488
2488
  }), distinctUntilChanged(), shareReplay(1));