@dsivd/prestations-ng 15.2.3-beta6 → 15.2.3-beta7

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.
@@ -32,15 +32,12 @@ import weekOfYear from 'dayjs/plugin/weekOfYear';
32
32
  /* eslint-disable @typescript-eslint/no-explicit-any */
33
33
  const IAM_SESSION_EXPIRED_HEADER = 'iam-session-expired';
34
34
  const CYBER_LOGIN_PATH = '/100018/login';
35
- const PORTAIL_IAM_ACV_EXTRA_PATH = 'portail.vd.ch:443/iamlogin';
36
- const PORTAIL_IAM_ACV_INTRA_PATH = 'portail.etat-de-vaud.ch:443/iamlogin';
35
+ const ACV_LOGIN_PATH = '/iamlogin';
37
36
  const isIamExpiredHeader = (event) => !!event.headers.get(IAM_SESSION_EXPIRED_HEADER);
38
37
  const isRedirectionToIamACV = (event) => {
39
38
  const isRedirection = event.status === 302 /* Found */;
40
39
  const location = event.headers.get('Location');
41
- return (isRedirection &&
42
- (location?.includes(PORTAIL_IAM_ACV_EXTRA_PATH) ||
43
- location?.includes(PORTAIL_IAM_ACV_INTRA_PATH)));
40
+ return isRedirection && location?.includes(ACV_LOGIN_PATH);
44
41
  };
45
42
  const isRedirectionToCyberLogin = (event) => {
46
43
  const isRedirection = event.status === 302 /* Found */;
@@ -49,30 +46,31 @@ const isRedirectionToCyberLogin = (event) => {
49
46
  };
50
47
  class IamExpiredInterceptorService {
51
48
  constructor() {
52
- this._iamExpirationHeaderPresence = new Subject();
49
+ this._isIamSessionExpired = new Subject();
53
50
  }
54
- get iamExpirationHeaderPresence() {
55
- return this._iamExpirationHeaderPresence.asObservable();
51
+ get isIamSessionExpired() {
52
+ return this._isIamSessionExpired.asObservable();
56
53
  }
57
54
  intercept(req, next) {
58
55
  return next.handle(req).pipe(map(event => {
59
- console.log('event', event);
56
+ console.log('event', typeof event, event);
60
57
  if (event instanceof HttpResponse) {
61
58
  if (isIamExpiredHeader(event) ||
62
59
  isRedirectionToIamACV(event) ||
63
60
  isRedirectionToCyberLogin(event)) {
64
- this._iamExpirationHeaderPresence.next(true);
61
+ this._isIamSessionExpired.next(true);
65
62
  }
66
63
  }
67
64
  return event;
68
65
  }), catchError(this.handleError.bind(this)));
69
66
  }
70
67
  handleError(err) {
68
+ console.log('err', typeof err, err);
71
69
  if (err instanceof HttpErrorResponse) {
72
- if (err.status === 200) {
70
+ if (err.status === 200 /* Ok */) {
73
71
  const isLogin = err.url.indexOf(CYBER_LOGIN_PATH) > 0;
74
72
  if (isLogin) {
75
- this._iamExpirationHeaderPresence.next(true);
73
+ this._isIamSessionExpired.next(true);
76
74
  }
77
75
  }
78
76
  }
@@ -9938,7 +9936,7 @@ class RedirectComponent {
9938
9936
  this.modalHeaderText = 'Information';
9939
9937
  this.modalBodyText = `<p>Votre session a expiré.</p>
9940
9938
  <p>Vous pouvez vous connecter à nouveau pour continuer à utiliser nos services.</p>`;
9941
- this.iamInterceptor.iamExpirationHeaderPresence
9939
+ this.iamInterceptor.isIamSessionExpired
9942
9940
  .pipe(first())
9943
9941
  .subscribe(() => this.showModal());
9944
9942
  }