@@ -8,11 +8,14 @@ import {
88 timer ,
99} from 'rxjs' ;
1010import {
11+ catchError ,
12+ finalize ,
1113 map ,
1214 mergeMap ,
1315 retryWhen ,
1416 switchMap ,
1517 take ,
18+ tap ,
1619 timeout ,
1720} from 'rxjs/operators' ;
1821import { AuthStateService } from '../auth-state/auth-state.service' ;
@@ -24,6 +27,8 @@ import { RefreshSessionIframeService } from '../iframe/refresh-session-iframe.se
2427import { SilentRenewService } from '../iframe/silent-renew.service' ;
2528import { LoggerService } from '../logging/logger.service' ;
2629import { LoginResponse } from '../login/login-response' ;
30+ import { EventTypes } from '../public-events/event-types' ;
31+ import { PublicEventsService } from '../public-events/public-events.service' ;
2732import { StoragePersistenceService } from '../storage/storage-persistence.service' ;
2833import { UserService } from '../user-data/user.service' ;
2934import { FlowHelper } from '../utils/flowHelper/flow-helper.service' ;
@@ -39,6 +44,8 @@ export class RefreshSessionService {
3944
4045 private readonly loggerService = inject ( LoggerService ) ;
4146
47+ private readonly publicEventsService = inject ( PublicEventsService ) ;
48+
4249 private readonly silentRenewService = inject ( SilentRenewService ) ;
4350
4451 private readonly authStateService = inject ( AuthStateService ) ;
@@ -76,8 +83,19 @@ export class RefreshSessionService {
7683 this . persistCustomParams ( extraCustomParams , config ) ;
7784
7885 // Best place ?
86+ this . publicEventsService . fireEvent ( EventTypes . ManualRenewStarted ) ;
87+
7988 return this . forceRefreshSession ( config , allConfigs , extraCustomParams ) . pipe (
89+ catchError ( ( error ) => {
90+ this . loggerService . logError ( config , 'manual renew failed!' , error ) ;
91+ this . publicEventsService . fireEvent ( EventTypes . ManualRenewFailed , error ) ;
92+
93+ return throwError ( ( ) => new Error ( error ) ) ;
94+ } ) ,
8095 finalize ( ( ) => this . flowsDataService . resetSilentRenewRunning ( config ) ) ,
96+ tap ( ( ) =>
97+ this . publicEventsService . fireEvent ( EventTypes . ManualRenewFinished )
98+ )
8199 ) ;
82100 }
83101
0 commit comments