@dsivd/prestations-ng 18.2.4-beta.4 → 18.2.4-beta.6
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';
|
|
@@ -1922,30 +1922,42 @@ class IamExpiredInterceptorService {
|
|
|
1922
1922
|
this._isIamSessionExpired.next(true);
|
|
1923
1923
|
}
|
|
1924
1924
|
intercept(req, next) {
|
|
1925
|
-
// Skip interceptor for the preliminary
|
|
1926
|
-
if (req.headers.has('X-Skip-Interceptor')
|
|
1925
|
+
// Skip interceptor for the preliminary requests
|
|
1926
|
+
if (req.headers.has('X-Skip-Interceptor') ||
|
|
1927
|
+
req.url.includes(APP_INFO_API_URL) ||
|
|
1928
|
+
req.url.includes(SESSION_INFO_API_URL)) {
|
|
1929
|
+
console.log('skipping interceptor for req : ', req);
|
|
1927
1930
|
return next.handle(req);
|
|
1928
1931
|
}
|
|
1929
|
-
const isDevEnv = this.appInfoService.data.pipe(map(appInfo => appInfo.environment.toUpperCase() === 'CO')
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
headers: new HttpHeaders({
|
|
1935
|
-
'X-Skip-Interceptor': 'true'
|
|
1936
|
-
})
|
|
1937
|
-
})
|
|
1938
|
-
.pipe(catchError(() => of(null)));
|
|
1939
|
-
return (!isDev && isConnected ? renewIamSession : of(null)).pipe(switchMap(() => next.handle(req).pipe(map(event => {
|
|
1940
|
-
if (event instanceof HttpResponseBase) {
|
|
1941
|
-
if (hasIamExpiredHeader(event) ||
|
|
1942
|
-
isRedirectionToLogin(event)) {
|
|
1943
|
-
this.setIamSessionExpiredManually();
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
return event;
|
|
1947
|
-
}), catchError(this.handleError.bind(this)))));
|
|
1932
|
+
const isDevEnv = this.appInfoService.data.pipe(map(appInfo => appInfo.environment.toUpperCase() === 'CO'), tap(result => {
|
|
1933
|
+
console.log('isDevEnv', result);
|
|
1934
|
+
}));
|
|
1935
|
+
const isUserConnected = this.sessionInfoService.data.pipe(map(sessionInfo => !!sessionInfo?.context), tap(result => {
|
|
1936
|
+
console.log('isUserConnected', result);
|
|
1948
1937
|
}));
|
|
1938
|
+
return combineLatest([isDevEnv, isUserConnected]).pipe(take(1), switchMap(([isDev, isConnected]) => (!isDev && isConnected
|
|
1939
|
+
? this.getRenewIamSession()
|
|
1940
|
+
: of(null)).pipe(switchMap(() => next.handle(req).pipe(map(event => {
|
|
1941
|
+
if (event instanceof HttpResponseBase) {
|
|
1942
|
+
if (hasIamExpiredHeader(event) ||
|
|
1943
|
+
isRedirectionToLogin(event)) {
|
|
1944
|
+
this.setIamSessionExpiredManually();
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
return event;
|
|
1948
|
+
}), catchError(this.handleError.bind(this)))))));
|
|
1949
|
+
}
|
|
1950
|
+
getRenewIamSession() {
|
|
1951
|
+
// call session info through RP IAM (prestations.vd.ch)
|
|
1952
|
+
// this renews the session since it is a "securised" endpoint
|
|
1953
|
+
// use OPTIONS to avoid extra load on session info
|
|
1954
|
+
return this.http
|
|
1955
|
+
.options('/sessioninfo/v2/me', {
|
|
1956
|
+
headers: new HttpHeaders({
|
|
1957
|
+
'X-Skip-Interceptor': 'true'
|
|
1958
|
+
})
|
|
1959
|
+
})
|
|
1960
|
+
.pipe(catchError(() => of(null)));
|
|
1949
1961
|
}
|
|
1950
1962
|
handleError(err) {
|
|
1951
1963
|
if (err instanceof HttpErrorResponse) {
|