feat: init and fork some code from angular-auth-oidc-client
Some checks are pending
Build, Lint & Test Lib / Built, Lint and Test Library (push) Waiting to run
Build, Lint & Test Lib / Angular latest (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest Standalone & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular 16 & RxJs 6 (push) Blocked by required conditions
Build, Lint & Test Lib / Angular V16 (push) Blocked by required conditions
Docs / Build and Deploy Docs Job (push) Waiting to run
Docs / Close Pull Request Job (push) Waiting to run
Some checks are pending
Build, Lint & Test Lib / Built, Lint and Test Library (push) Waiting to run
Build, Lint & Test Lib / Angular latest (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest Standalone & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular 16 & RxJs 6 (push) Blocked by required conditions
Build, Lint & Test Lib / Angular V16 (push) Blocked by required conditions
Docs / Build and Deploy Docs Job (push) Waiting to run
Docs / Close Pull Request Job (push) Waiting to run
This commit is contained in:
44
src/callback/refresh-session-refresh-token.service.ts
Normal file
44
src/callback/refresh-session-refresh-token.service.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { inject, Injectable } from 'injection-js';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError, finalize } from 'rxjs/operators';
|
||||
import { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { CallbackContext } from '../flows/callback-context';
|
||||
import { FlowsService } from '../flows/flows.service';
|
||||
import { ResetAuthDataService } from '../flows/reset-auth-data.service';
|
||||
import { LoggerService } from '../logging/logger.service';
|
||||
import { IntervalService } from './interval.service';
|
||||
|
||||
@Injectable()
|
||||
export class RefreshSessionRefreshTokenService {
|
||||
private readonly loggerService = inject(LoggerService);
|
||||
|
||||
private readonly resetAuthDataService = inject(ResetAuthDataService);
|
||||
|
||||
private readonly flowsService = inject(FlowsService);
|
||||
|
||||
private readonly intervalService = inject(IntervalService);
|
||||
|
||||
refreshSessionWithRefreshTokens(
|
||||
config: OpenIdConfiguration,
|
||||
allConfigs: OpenIdConfiguration[],
|
||||
customParamsRefresh?: { [key: string]: string | number | boolean }
|
||||
): Observable<CallbackContext> {
|
||||
this.loggerService.logDebug(config, 'BEGIN refresh session Authorize');
|
||||
let refreshTokenFailed = false;
|
||||
|
||||
return this.flowsService
|
||||
.processRefreshToken(config, allConfigs, customParamsRefresh)
|
||||
.pipe(
|
||||
catchError((error) => {
|
||||
this.resetAuthDataService.resetAuthorizationData(config, allConfigs);
|
||||
refreshTokenFailed = true;
|
||||
|
||||
return throwError(() => new Error(error));
|
||||
}),
|
||||
finalize(
|
||||
() =>
|
||||
refreshTokenFailed && this.intervalService.stopPeriodicTokenCheck()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user