1+ import { provideHttpClient , withInterceptorsFromDi } from '@angular/common/http' ;
12import {
2- provideHttpClient ,
3- withInterceptors ,
4- withInterceptorsFromDi ,
5- } from '@angular/common/http' ;
6- import {
3+ ENVIRONMENT_INITIALIZER ,
74 EnvironmentProviders ,
85 InjectionToken ,
96 Provider ,
107 inject ,
11- provideEnvironmentInitializer ,
12- provideZoneChangeDetection ,
138} from '@angular/core' ;
149import { provideAnimations } from '@angular/platform-browser/animations' ;
1510import {
@@ -19,18 +14,12 @@ import {
1914 withRouterConfig ,
2015} from '@angular/router' ;
2116
22- import {
23- INCLUDE_BEARER_TOKEN_INTERCEPTOR_CONFIG ,
24- IncludeBearerTokenCondition ,
25- createInterceptorCondition ,
26- includeBearerTokenInterceptor ,
27- } from 'keycloak-angular' ;
2817import { provideEnvironmentNgxMask } from 'ngx-mask' ;
2918
3019import { provideHttpInterceptors } from '@bcgov/shared/data-access' ;
3120import { provideMaterialConfig , provideNgxProgressBar } from '@bcgov/shared/ui' ;
3221
33- import { provideKeycloakAngular } from '@app/modules/keycloak/keycloak.config ' ;
22+ import { provideKeycloak } from '@app/modules/keycloak/keycloak' ;
3423
3524export interface CoreOptions {
3625 routes : Routes ;
@@ -39,30 +28,18 @@ export interface CoreOptions {
3928// create unique injection token for the guard
4029export const CORE_GUARD = new InjectionToken < string > ( 'CORE_GUARD' ) ;
4130
42- const bearerTokenCondition =
43- createInterceptorCondition < IncludeBearerTokenCondition > ( {
44- urlPattern : / ^ ( .+ ) ? $ / i,
45- } ) ;
46-
4731export function provideCore (
4832 options : CoreOptions ,
4933) : ( Provider | EnvironmentProviders ) [ ] {
5034 return [
51- provideKeycloakAngular ( ) ,
52- provideZoneChangeDetection ( { eventCoalescing : true } ) ,
5335 { provide : CORE_GUARD , useValue : 'CORE_GUARD' } ,
54- {
55- provide : INCLUDE_BEARER_TOKEN_INTERCEPTOR_CONFIG ,
56- useValue : [ bearerTokenCondition ] ,
57- } ,
5836 provideAnimations ( ) ,
5937 provideNgxProgressBar ( ) ,
6038 provideMaterialConfig ( ) ,
6139 provideEnvironmentNgxMask ( ) ,
6240 provideHttpClient (
6341 // DI-based interceptors must be explicitly enabled.
6442 withInterceptorsFromDi ( ) ,
65- withInterceptors ( [ includeBearerTokenInterceptor ] ) ,
6643 ) ,
6744 provideHttpInterceptors ( ) ,
6845 provideRouter (
@@ -79,11 +56,12 @@ export function provideCore(
7956 // disabled debug tracing
8057 // withDebugTracing()
8158 ) ,
59+ provideKeycloak ( ) ,
8260 // order matters
8361 // (especially when accessing some of the above defined providers)
8462 // init has to be last
8563 {
86- provide : provideEnvironmentInitializer ,
64+ provide : ENVIRONMENT_INITIALIZER ,
8765 multi : true ,
8866 useValue ( ) : void {
8967 const coreGuard = inject ( CORE_GUARD , {
0 commit comments