@dsivd/prestations-ng 18.2.4-beta.5 → 18.2.4-beta.7
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.
|
Binary file
|
|
@@ -5,7 +5,7 @@ import { ActivatedRoute, NavigationStart, RouterModule, NavigationEnd, RouterLin
|
|
|
5
5
|
import { of, Subject, BehaviorSubject, combineLatest, throwError, switchMap as switchMap$1, forkJoin, tap as tap$1, concat, toArray, EMPTY, startWith, filter as filter$1, merge, withLatestFrom, debounceTime as debounceTime$1, map as map$1 } from 'rxjs';
|
|
6
6
|
import { map, shareReplay, filter, tap, debounceTime, catchError, switchMap, take, first, throttleTime, mergeMap, share, finalize, distinctUntilChanged } from 'rxjs/operators';
|
|
7
7
|
import * as i1 from '@angular/common/http';
|
|
8
|
-
import { HttpStatusCode, HttpClient,
|
|
8
|
+
import { HttpStatusCode, HttpClient, HttpResponseBase, HttpHeaders, HttpErrorResponse, HttpParams, HttpEventType, HttpResponse, HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
|
9
9
|
import * as i3 from '@angular/forms';
|
|
10
10
|
import { NgModel, NgForm, FormsModule } from '@angular/forms';
|
|
11
11
|
import * as i2 from '@angular/common';
|
|
@@ -1911,7 +1911,7 @@ const isRedirectionToLogin = (event) => {
|
|
|
1911
1911
|
class IamExpiredInterceptorService {
|
|
1912
1912
|
constructor() {
|
|
1913
1913
|
this.http = inject(HttpClient);
|
|
1914
|
-
|
|
1914
|
+
// private appInfoService = inject(ApplicationInfoService);
|
|
1915
1915
|
this.sessionInfoService = inject(SessionInfo);
|
|
1916
1916
|
this._isIamSessionExpired = new BehaviorSubject(false);
|
|
1917
1917
|
}
|
|
@@ -1924,30 +1924,41 @@ class IamExpiredInterceptorService {
|
|
|
1924
1924
|
intercept(req, next) {
|
|
1925
1925
|
// Skip interceptor for the preliminary requests
|
|
1926
1926
|
if (req.headers.has('X-Skip-Interceptor') ||
|
|
1927
|
-
req.url.includes(APP_INFO_API_URL) ||
|
|
1927
|
+
// req.url.includes(APP_INFO_API_URL) ||
|
|
1928
1928
|
req.url.includes(SESSION_INFO_API_URL)) {
|
|
1929
|
+
console.log('skipping interceptor for req : ', req);
|
|
1929
1930
|
return next.handle(req);
|
|
1930
1931
|
}
|
|
1931
|
-
const isDevEnv = this.appInfoService.data.pipe(
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
})
|
|
1940
|
-
.pipe(catchError(() => of(null)));
|
|
1941
|
-
return (!isDev && isConnected ? renewIamSession : of(null)).pipe(switchMap(() => next.handle(req).pipe(map(event => {
|
|
1942
|
-
if (event instanceof HttpResponseBase) {
|
|
1943
|
-
if (hasIamExpiredHeader(event) ||
|
|
1944
|
-
isRedirectionToLogin(event)) {
|
|
1945
|
-
this.setIamSessionExpiredManually();
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
return event;
|
|
1949
|
-
}), catchError(this.handleError.bind(this)))));
|
|
1932
|
+
// const isDevEnv = this.appInfoService.data.pipe(
|
|
1933
|
+
// map(appInfo => appInfo.environment.toUpperCase() === 'CO'),
|
|
1934
|
+
// tap(result => {
|
|
1935
|
+
// console.log('isDevEnv', result);
|
|
1936
|
+
// })
|
|
1937
|
+
// );
|
|
1938
|
+
const isUserConnected = this.sessionInfoService.data.pipe(map(sessionInfo => !!sessionInfo?.context), tap(result => {
|
|
1939
|
+
console.log('isUserConnected', result);
|
|
1950
1940
|
}));
|
|
1941
|
+
return combineLatest([isUserConnected]).pipe(take(1), switchMap(([isConnected]) => (isConnected ? this.getRenewIamSession() : of(null)).pipe(switchMap(() => next.handle(req).pipe(map(event => {
|
|
1942
|
+
if (event instanceof HttpResponseBase) {
|
|
1943
|
+
if (hasIamExpiredHeader(event) ||
|
|
1944
|
+
isRedirectionToLogin(event)) {
|
|
1945
|
+
this.setIamSessionExpiredManually();
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
return event;
|
|
1949
|
+
}), catchError(this.handleError.bind(this)))))));
|
|
1950
|
+
}
|
|
1951
|
+
getRenewIamSession() {
|
|
1952
|
+
// call session info through RP IAM (prestations.vd.ch)
|
|
1953
|
+
// this renews the session since it is a "securised" endpoint
|
|
1954
|
+
// use OPTIONS to avoid extra load on session info
|
|
1955
|
+
return this.http
|
|
1956
|
+
.options('/sessioninfo/v2/me', {
|
|
1957
|
+
headers: new HttpHeaders({
|
|
1958
|
+
'X-Skip-Interceptor': 'true'
|
|
1959
|
+
})
|
|
1960
|
+
})
|
|
1961
|
+
.pipe(catchError(() => of(null)));
|
|
1951
1962
|
}
|
|
1952
1963
|
handleError(err) {
|
|
1953
1964
|
if (err instanceof HttpErrorResponse) {
|